<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hac.the.planet.blog</title>
	<atom:link href="http://hactheplanet.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://hactheplanet.com/blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Tue, 27 Mar 2012 15:20:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Google Book Downloader Update: Page ranges</title>
		<link>http://hactheplanet.com/blog/175</link>
		<comments>http://hactheplanet.com/blog/175#comments</comments>
		<pubDate>Tue, 27 Mar 2012 15:20:40 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Book Downloader]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=175</guid>
		<description><![CDATA[You can now specify a range of pages: Download here.]]></description>
			<content:encoded><![CDATA[<p>You can now specify a range of pages:</p>
<p><a href="http://hactheplanet.com/blog/wp-content/uploads/2012/03/Screen-shot-2012-03-27-at-7.23.49-PM.png"><img class="aligncenter size-medium wp-image-200" title="Screen shot 2012-03-27 at 7.23.49 PM" src="http://hactheplanet.com/blog/wp-content/uploads/2012/03/Screen-shot-2012-03-27-at-7.23.49-PM-300x151.png" alt="" width="300" height="151" /></a></p>
<p>Download <a href="http://hactheplanet.com/mac/googlebookdownloader">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/175/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Book Downloader Update: High Quality</title>
		<link>http://hactheplanet.com/blog/159</link>
		<comments>http://hactheplanet.com/blog/159#comments</comments>
		<pubDate>Tue, 13 Sep 2011 04:14:16 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Book Downloader]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scraping]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=159</guid>
		<description><![CDATA[Until now, Google Book Downloader has used the default image resolution provided by Google, even though books.google.com allows you to zoom in on pages to see higher resolution. Version 2.1 fixes this, finding the highest resolution available for every book &#8230; <a href="http://hactheplanet.com/blog/159">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Until now, Google Book Downloader has used the default image resolution provided by Google, even though books.google.com allows you to zoom in on pages to see higher resolution. Version 2.1 fixes this, finding the highest resolution available for every book you download. To download Google Book Downloader, see the <a href="http://hactheplanet.com/mac/googlebookdownloader">app page here</a>.</p>
<div id="attachment_176" class="wp-caption aligncenter" style="width: 310px"><a href="http://hactheplanet.com/blog/wp-content/uploads/2011/09/Screen-shot-2011-09-12-at-11.40.02-PM.png"><img class="size-medium wp-image-176" title="Quality comparison between GBD v. 2.0.1 and 2.1" src="http://hactheplanet.com/blog/wp-content/uploads/2011/09/Screen-shot-2011-09-12-at-11.40.02-PM-300x208.png" alt="" width="300" height="208" /></a><p class="wp-caption-text">Quality comparison between GBD v. 2.0.1 and 2.1: Click to see a larger version where you can see the difference.</p></div>
<p style="text-align: left;">As you can see, books downloaded with this new version look <em>much</em> better. Now, the technical details:</p>
<p>Books on Google Books have a zoom in button that allows you to see the pages on most books in higher detail. In order to get GBD to download higher detail images, I needed to somehow hijack this button. My first attempt was, of course, with Javascript. But the Javascript code that does the online zooming turned out to be very evasive—hidden inside layers of anonymous functions and called by Google&#8217;s custom event handling code. I eventually gave up on this.</p>
<p>In order to get around this problem, I used Javascript to first find the button I wanted to click, (using getElementById) but rather then trying to &#8220;click&#8221; the button with Javascript, passed the location of the button to Objective-C code. The native Objective-C code then used an NSEvent to simulate a click in the webpage.</p>
<p>If you&#8217;re interested, this code is all available on Github. It simply adds a few methods to WebKit&#8217;s WebView which allow you to find an element in a web page, click on a location in a web page, or click on an element.</p>
<ul>
<li><a href="https://github.com/hac/googlebookdownloader/blob/7e1e6ba8d481d98941c43ad872529bc3e0f026e2/WebView+FakeClicking.h">WebView+FakeClicking.h </a></li>
<li><a href="https://github.com/hac/googlebookdownloader/blob/7e1e6ba8d481d98941c43ad872529bc3e0f026e2/WebView+FakeClicking.m">WebView+FakeClicking.m </a></li>
<li><a href="https://github.com/hac/googlebookdownloader/blob/7e1e6ba8d481d98941c43ad872529bc3e0f026e2/GetPosition.js">GetPosition.js</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/159/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Book Downloader Update: Version 2.0</title>
		<link>http://hactheplanet.com/blog/125</link>
		<comments>http://hactheplanet.com/blog/125#comments</comments>
		<pubDate>Mon, 29 Aug 2011 03:41:31 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Book Downloader]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Scraping]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=125</guid>
		<description><![CDATA[Google Book Downloader 2.0 is out! What&#8217;s new: much faster, fewer bugs, and less important things. To download, see the product page here. If you are into the technical details, maybe you are wondering what went on behind the scenes &#8230; <a href="http://hactheplanet.com/blog/125">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Google Book Downloader 2.0 is out! What&#8217;s new: much faster, fewer bugs, and less important things. To download, see the product page <a href="http://hactheplanet.com/mac/googlebookdownloader">here</a>.</p>
<p style="text-align: center;"><a href="http://hactheplanet.com/blog/wp-content/uploads/2011/08/Screen-shot-2011-08-28-at-10.47.12-PM.png"><img class="size-medium wp-image-160 aligncenter" title="Google Book Downloader downloading a Google Book" src="http://hactheplanet.com/blog/wp-content/uploads/2011/08/Screen-shot-2011-08-28-at-10.47.12-PM-300x96.png" alt="" width="300" height="96" /></a></p>
<p>If you are into the technical details, maybe you are wondering what went on behind the scenes to make such improvements. First, a quick background on scraping:</p>
<p><strong>One way to scrape:</strong> Start with an AJAX web app that you want to borrow some data from. Reverse engineer it until you understand the API that it is using to get data from the server. Then re-engineer your app to use this API.</p>
<p>However, there is <strong>another way to scrape</strong>: Start with someone else&#8217;s AJAX web app. Load it into a web browser engine. Use whatever hooks the web browser engine provides to do things like 1) run your own JavaScript on the page and 2) monitor the network traffic of the web app. Compared to the first way to scrape, this requires a lot less thinking!</p>
<p>As you may have guessed, GBD 1 used the first method, while GBD 2 used the second method. Not only does this prevent me from having to worry about Google&#8217;s AJAX calls, but it also simplifies the source code of the application. It also has the nice effect of speeding up the application.</p>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/125/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>[OS X] Install Pwntcha</title>
		<link>http://hactheplanet.com/blog/132</link>
		<comments>http://hactheplanet.com/blog/132#comments</comments>
		<pubDate>Sat, 08 Jan 2011 16:43:46 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CAPTCHA]]></category>
		<category><![CDATA[OCR]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Pwntcha]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=132</guid>
		<description><![CDATA[Pwntcha is an open source tool for breaking CAPTCHAs. While it is a few years old and only works for very simple CAPTCHAs, it&#8217;s still and interesting project and would be a good place to start if you wanted to &#8230; <a href="http://hactheplanet.com/blog/132">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://caca.zoy.org/wiki/PWNtcha">Pwntcha</a> is an open source tool for breaking <a href="http://en.wikipedia.org/wiki/CAPTCHA">CAPTCHAs</a>. While it is a few years old and only works for very simple CAPTCHAs, it&#8217;s still and interesting project and would be a good place to start if you wanted to write a program to break more complex ones. To install it on OS X:</p>
<ol>
<li>Install the Simple DirectMedia Layer library: From Terminal and with MacPorts installed, type
<pre class="brush: bash; title: ;">sudo port install libsdl_image</pre>
<p>As an alternative, installing imlib2 would probably also work.</p>
<p>I encountered an error installing db46, one of the dependencies of libsdl and imlib2, which I fixed by installing the <a href="http://adcdownload.apple.com/Java/java_for_mac_os_x_10.6_update_3_developer_package/javadeveloper_10.6_10m3261.dmg">Java for Mac OS X 10.6 Update 3 Developer Package</a>.
</li>
<li>Check out a copy of Pwntcha via SVN:
<pre class="brush: bash; title: ;">svn co svn://svn.zoy.org/caca/pwntcha/trunk pwntcha</pre>
</li>
<li>Compile:
<pre class="brush: bash; title: ;">cd pwntcha
./bootstrap
./configure
sudo make install</pre>
</li>
<li>Lastly, run the program:
<pre class="brush: bash; title: ;">curl -O http://hactheplanet.com/blog/wp-content/uploads/2011/01/authimage.jpeg
pwntcha authimage.jpeg</pre>
</li>
</ol>
<p>
<a href="http://hactheplanet.com/blog/wp-content/uploads/2011/01/authimage.jpeg"><img class="alignnone size-full wp-image-143" title="authimage" src="http://hactheplanet.com/blog/wp-content/uploads/2011/01/authimage.jpeg" alt="" width="155" height="50" /></a><br />
The image is analyzed to be 5Z28AF.</p>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/132/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>[Ruby] Automate Facebook</title>
		<link>http://hactheplanet.com/blog/121</link>
		<comments>http://hactheplanet.com/blog/121#comments</comments>
		<pubDate>Tue, 04 Jan 2011 01:59:02 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bots]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=121</guid>
		<description><![CDATA[Using the Ruby Mechanize library, I have been writing a Ruby class to allow automation of parts of Facebook like friending, status updating, and messaging. You can get the class here and use it like so: #!/usr/bin/ruby # Require FacebookBot.rb &#8230; <a href="http://hactheplanet.com/blog/121">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Using the <a href="http://mechanize.rubyforge.org/mechanize/">Ruby Mechanize</a> library, I have been writing a Ruby class to allow automation of parts of Facebook like friending, status updating, and messaging.</p>
<p>You can <a href="https://gist.github.com/764284">get the class here</a> and use it like so:</p>
<pre class="brush: ruby; title: ;">
#!/usr/bin/ruby

# Require FacebookBot.rb from the same directory.
require File.join(File.dirname(__FILE__), 'FacebookBot.rb')

# Log in.
fb = FacebookBot.new(&quot;example@example.com&quot;, &quot;secret&quot;)

# Accept all friend requests.
fb.acceptRequests

# Friend a whole page of suggested friends.
fb.suggestedFriends.each { |friendId| fb.requestFriend(friendId) }

# Display all personal messages and recent wall posts.
require &quot;pp&quot;
pp fb.personalMessages
pp fb.recentPosts
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/121/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>[OS X] View MHTML Files</title>
		<link>http://hactheplanet.com/blog/60</link>
		<comments>http://hactheplanet.com/blog/60#comments</comments>
		<pubDate>Mon, 03 Jan 2011 01:10:37 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MHTML]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=60</guid>
		<description><![CDATA[Using code from the UnMHT QuickLook project, I put together an app that renders MHTML files using WebKit on OS X. Features: print, export to PDF, and export to webarchive. Download App Source Code]]></description>
			<content:encoded><![CDATA[<p>Using code from the <a href="http://www.unmht.org/ql_unmht/">UnMHT QuickLook</a> project, I put together an app that renders <a href="http://en.wikipedia.org/wiki/MHTML">MHTML</a> files using WebKit on OS X. Features: print, export to PDF, and export to webarchive.</p>
<p style="text-align: center;"><a href="http://hactheplanet.com/blog/wp-content/uploads/2011/01/Screen-shot-2011-01-02-at-8.14.02-PM.png"><img class="size-medium wp-image-122 aligncenter" title="Screen shot 2011-01-02 at 8.14.02 PM" src="http://hactheplanet.com/blog/wp-content/uploads/2011/01/Screen-shot-2011-01-02-at-8.14.02-PM-300x202.png" alt="" width="300" height="202" /></a></p>
<ul>
<li><a href="https://github.com/downloads/hac/mhtmlviewer/MHTML%20Viewer%201.0.dmg">Download App</a></li>
<li><a href="http://github.com/hac/mhtmlviewer">Source Code</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/60/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Book Downloader Update: Download JPEGs</title>
		<link>http://hactheplanet.com/blog/64</link>
		<comments>http://hactheplanet.com/blog/64#comments</comments>
		<pubDate>Thu, 02 Dec 2010 02:49:19 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google Book Downloader]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=64</guid>
		<description><![CDATA[Google Book Downloader is my app that downloads Google Books/Book Previews in PDF format. The major problem with it so far has been that when it encodes JPEGs from Google&#8217;s servers into PDF format, there is a loss in quality &#8230; <a href="http://hactheplanet.com/blog/64">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Google Book Downloader is my app that downloads Google Books/Book Previews in PDF format. The major problem with it so far has been that when it encodes JPEGs from Google&#8217;s servers into PDF format, there is a loss in quality of the image. So far I have found no way to avoid this loss of quality when making a PDF from JPEGs.</p>
<p>Today I&#8217;m releasing a new version (1.2) of Google Book Downloader in which you can choose not to save a PDF, but a folder of JPEGs. The folder also has an index.html file that makes it convenient to read the JPEGS in the right order.</p>
<p style="text-align: left;">Download it <a href="http://hactheplanet.com/mac/googlebookdownloader">here</a>.<br />
<a href="http://hactheplanet.com/blog/wp-content/uploads/2010/10/Screen-shot-2010-12-01-at-9.46.51-PM.png"><img class="size-medium wp-image-106 aligncenter" title="Screen shot 2010-12-01 at 9.46.51 PM" src="http://hactheplanet.com/blog/wp-content/uploads/2010/10/Screen-shot-2010-12-01-at-9.46.51-PM-300x128.png" alt="" width="300" height="128" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/64/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Replacing C Functions with Dynamic Linking in OS X</title>
		<link>http://hactheplanet.com/blog/80</link>
		<comments>http://hactheplanet.com/blog/80#comments</comments>
		<pubDate>Sun, 24 Oct 2010 16:48:46 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[GCC]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=80</guid>
		<description><![CDATA[Say we wanted to make a command line program like date use a fake time instead of the current one. We could do this by supplying a time() function to replace the time() function in libSystem. How do we know &#8230; <a href="http://hactheplanet.com/blog/80">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Say we wanted to make a command line program like date use a fake time instead of the current one. We could do this by supplying a time() function to replace the time() function in libSystem.</p>
<p>How do we know that date uses time()? We use <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/nm.1.html">nm</a>, which lists all the symbols used by a particular program:</p>
<pre class="brush: plain; title: ;">
$ nm -m /bin/date | grep _time
(undefined [lazy bound]) external _time (from libSystem)
</pre>
<p>Once we know what function to replace, we can write a replacement function:</p>
<pre class="brush: cpp; title: ;">
// time.c

#include &lt;sys/time.h&gt;

// This function will override the one in /usr/lib/libSystem.dylib.
time_t time(time_t *tloc)
{
    // January 1st, 2000.
    struct tm timeStruct;
    timeStruct.tm_year = 2000 - 1900;
    timeStruct.tm_mon = 0;
    timeStruct.tm_mday = 1;
    timeStruct.tm_hour = 0;
    timeStruct.tm_min = 0;
    timeStruct.tm_sec = 0;
    timeStruct.tm_isdst = -1;

    *tloc = mktime(&amp;timeStruct);
    return *tloc;
}
</pre>
<p>Then we compile the code as a dynamic library:</p>
<pre class="brush: plain; title: ;">
gcc -c time.c
gcc -flat_namespace -dynamiclib -current_version 1.0 time.o -o libTime.dylib
</pre>
<p>To tell OS X&#8217;s dynamic linker to load our dynamic library, we need to set DYLD_INSERT_LIBRARIES to the path of the library. We also need to set DYLD_FORCE_FLAT_NAMESPACE, or our function will not override the old one. These settings and more can be found on the <a href="http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/dyld.1.html">dyld man page</a>.</p>
<p>The result:</p>
<pre class="brush: bash; title: ;">
$ date
Sun Oct 24 13:21:12 EST 2010
</pre>
<pre class="brush: bash; title: ;">
$ DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./libTime.dylib date
Sat Jan  1 00:00:00 EST 2000
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/80/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Upcoming OS X App: Music Player/Downloader</title>
		<link>http://hactheplanet.com/blog/44</link>
		<comments>http://hactheplanet.com/blog/44#comments</comments>
		<pubDate>Sun, 24 Oct 2010 04:07:50 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://hactheplanet.com/blog/?p=44</guid>
		<description><![CDATA[Here is a screenshot of an app I plan on releasing soon. As you can see, it has an iTunes-like interface, with some extra features for downloading music. You can search YouTube for songs, and download them from YouTube directly into &#8230; <a href="http://hactheplanet.com/blog/44">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here is a screenshot of an app I plan on releasing soon. As you can see, it has an iTunes-like interface, with some extra features for downloading music. You can search YouTube for songs, and download them from YouTube directly into your music library.</p>
<p>Leave a comment or contact me if you would like to beta test.</p>
<p><a href="http://hactheplanet.com/blog/wp-content/uploads/2010/10/Screen-shot-2010-10-23-at-11.48.30-PM.png"><img class="size-full wp-image-65 alignleft" title="Screen shot 2010-10-23 at 11.48.30 PM" src="http://hactheplanet.com/blog/wp-content/uploads/2010/10/Screen-shot-2010-10-23-at-11.48.30-PM.png" alt="" width="1033" height="502" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/44/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>[PHP] Get Google’s Cache of a URL</title>
		<link>http://hactheplanet.com/blog/11</link>
		<comments>http://hactheplanet.com/blog/11#comments</comments>
		<pubDate>Mon, 30 Aug 2010 00:13:20 +0000</pubDate>
		<dc:creator>hac</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://localhost/~hac/domains/hactheplanet.com/public_html/blog/?p=11</guid>
		<description><![CDATA[This PHP function fetches the contents of a URL as it exists in Google&#8217;s cache: function cachedHTMLForURL($url) { // Request the cache from Google. $googleRequestURL = &#34;http://webcache.googleusercontent.com/search?q=&#34; . urlencode(&#34;cache:&#34; . $url); $googleResponse = file_get_contents($googleRequestURL); // Return false if Google did &#8230; <a href="http://hactheplanet.com/blog/11">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This PHP function fetches the contents of a URL as it exists in Google&#8217;s cache:</p>
<pre class="brush: php; title: ;">
function cachedHTMLForURL($url)
{
	// Request the cache from Google.
	$googleRequestURL = &quot;http://webcache.googleusercontent.com/search?q=&quot; . urlencode(&quot;cache:&quot; . $url);
	$googleResponse = file_get_contents($googleRequestURL);

	// Return false if Google did not have it.
	if (preg_match(&quot;/^.*&lt;title&gt;cache:/&quot;, $googleResponse))
	return false;

	// Remove the first 3 lines of the response, which is inserted by Google.
	$importantHTML = preg_replace(&quot;/^(.*\n){3}/&quot;, &quot;&quot;, $googleResponse);

	// Allow one line to be inserted, which corrects the base path of the site.
	preg_match_all(&quot;/&lt;base href=\&quot;[^\&quot;]*\&quot;&gt;/&quot;, $googleResponse, $matches);
	$base = $matches[0][0] . &quot;\n&quot;;

	return $base . $importantHTML;
}
</pre>
<p>Use like so:</p>
<pre class="brush: php; title: ;">
echo cachedHTMLForURL(&quot;http://news.google.com/&quot;);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://hactheplanet.com/blog/11/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

