<?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>grypto</title>
	<atom:link href="http://grypto.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://grypto.com</link>
	<description>just another tech blog</description>
	<lastBuildDate>Fri, 03 Jul 2009 20:17:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tuning MySQL Performance with a neat little perl script</title>
		<link>http://grypto.com/2009/07/03/tuning-mysql-performance-with-a-neat-little-perl-script/</link>
		<comments>http://grypto.com/2009/07/03/tuning-mysql-performance-with-a-neat-little-perl-script/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 20:14:38 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Tuning]]></category>
		<category><![CDATA[MySQLTuner]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=67</guid>
		<description><![CDATA[Searching randomly through Google for my next post topic, I came across a little MySQL Tuner perl script written by a RackSpace Senior Systems Engineer named Major Haden. Two things caught my eye.
1. It's always great to optimize things, especially MySQL.
2. Major is a seriously cool name.
Nothing about this script was lacking in coolness, so [...]]]></description>
			<content:encoded><![CDATA[<p>Searching randomly through Google for my next post topic, I came across a little MySQL Tuner perl script written by a RackSpace Senior Systems Engineer named Major Haden. Two things caught my eye.</p>
<p>1. It's always great to optimize things, especially MySQL.</p>
<p>2. Major is a seriously cool name.</p>
<p>Nothing about this script was lacking in coolness, so I decided to run it on my crappy little home FreeBSD development box.</p>
<p><code><br />
fetch http://mysqltuner.com/mysqltuner.pl<br />
chmod +x mysqltuner.pl<br />
./mysqltuner.pl<br />
</code></p>
<p>The result?</p>
<p><code><br />
 >>  MySQLTuner 1.0.0 - Major Hayden <major@mhtx.net><br />
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/<br />
 >>  Run with '--help' for additional options and output filtering<br />
Please enter your MySQL administrative login:<br />
Please enter your MySQL administrative password:</p>
<p>-------- General Statistics --------------------------------------------------<br />
[--] Skipped version check for MySQLTuner script<br />
[OK] Currently running supported MySQL version 5.1.35<br />
[OK] Operating on 32-bit architecture with less than 2GB RAM</p>
<p>-------- Storage Engine Statistics -------------------------------------------<br />
[--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster<br />
[--] Data in MyISAM tables: 756M (Tables: 26)<br />
[!!] InnoDB is enabled but isn't being used<br />
[!!] Total fragmented tables: 2</p>
<p>-------- Performance Metrics -------------------------------------------------<br />
[--] Up for: 6d 9h 42m 52s (5K q [0.010 qps], 23 conn, TX: 482K, RX: 5M)<br />
[--] Reads / Writes: 58% / 42%<br />
[--] Total buffers: 34.0M global + 2.7M per thread (151 max threads)<br />
[OK] Maximum possible memory usage: 439.8M (43% of installed RAM)<br />
[OK] Slow queries: 0% (0/5K)<br />
[OK] Highest usage of available connections: 1% (2/151)<br />
[OK] Key buffer size / total MyISAM indexes: 8.0M/395.4M<br />
[OK] Key buffer hit rate: 98.5% (32K cached / 472 reads)<br />
[!!] Query cache is disabled<br />
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 3 sorts)<br />
[OK] Temporary tables created on disk: 7% (3 on disk / 38 total)<br />
[!!] Thread cache is disabled<br />
[OK] Table cache hit rate: 87% (49 open / 56 opened)<br />
[OK] Open file limit used: 0% (98/11K)<br />
[OK] Table locks acquired immediately: 100% (5K immediate / 5K locks)<br />
[!!] Connections aborted: 13%</p>
<p>-------- Recommendations -----------------------------------------------------<br />
General recommendations:<br />
    Add skip-innodb to MySQL configuration to disable InnoDB<br />
    Run OPTIMIZE TABLE to defragment tables for better performance<br />
    Enable the slow query log to troubleshoot bad queries<br />
    Set thread_cache_size to 4 as a starting value<br />
    Your applications are not closing MySQL connections properly<br />
Variables to adjust:<br />
    query_cache_size (>= 8M)<br />
    thread_cache_size (start at 4)<br />
</code></p>
<p>Clearly I haven't gone anywhere near my MySQL config.</p>
]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/07/03/tuning-mysql-performance-with-a-neat-little-perl-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>10 Simple, Elegant, and Free Wordpress Themes</title>
		<link>http://grypto.com/2009/06/27/10-simple-elegant-and-free-wordpress-themes/</link>
		<comments>http://grypto.com/2009/06/27/10-simple-elegant-and-free-wordpress-themes/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 02:02:14 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Wordpress Themes]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=45</guid>
		<description><![CDATA[1. stylized

2. curiouslygreen

3. standardissue

4. nonzero

5. emporium

6. splendid

7. unembellished

8. reference

9. shallowgrunge

10. plainoffice

]]></description>
			<content:encoded><![CDATA[<h3>1. stylized</h3>
<p><a href="http://www.freewpthemes.net/preview/stylized"><img src="http://grypto.com/wp-content/uploads/2009/06/stylized.png" alt="stylized" /></a></p>
<h3>2. curiouslygreen</h3>
<p><a href="http://www.freewpthemes.net/preview/curiouslygreen"><img src="http://grypto.com/wp-content/uploads/2009/06/curiouslygreen.png" alt="curiouslygreen" /></a></p>
<h3>3. standardissue</h3>
<p><a href="http://www.freewpthemes.net/preview/standardissue"><img src="http://grypto.com/wp-content/uploads/2009/06/standardissue.png" alt="standardissue" /></a></p>
<h3>4. nonzero</h3>
<p><a href="http://www.freewpthemes.net/preview/nonzero"><img src="http://grypto.com/wp-content/uploads/2009/06/nonzero.png" alt="nonzero" /></a></p>
<h3>5. emporium</h3>
<p><a href="http://www.freewpthemes.net/preview/emporium"><img src="http://grypto.com/wp-content/uploads/2009/06/emporium.png" alt="emporium" /></a></p>
<h3>6. splendid</h3>
<p><a href="http://www.freewpthemes.net/preview/splendid"><img src="http://grypto.com/wp-content/uploads/2009/06/splendid.png" alt="splendid" /></a></p>
<h3>7. unembellished</h3>
<p><a href="http://www.freewpthemes.net/preview/unembellished"><img src="http://grypto.com/wp-content/uploads/2009/06/unembellished.png" alt="unembellished" /></a></p>
<h3>8. reference</h3>
<p><a href="http://www.freewpthemes.net/preview/reference"><img src="http://grypto.com/wp-content/uploads/2009/06/reference.png" alt="reference" /></a></p>
<h3>9. shallowgrunge</h3>
<p><a href="http://www.freewpthemes.net/preview/shallowgrunge"><img src="http://grypto.com/wp-content/uploads/2009/06/shallowgrunge.png" alt="shallowgrunge" /></a></p>
<h3>10. plainoffice</h3>
<p><a href="http://www.freewpthemes.net/preview/plainoffice"><img src="http://grypto.com/wp-content/uploads/2009/06/plainoffice.png" alt="plainoffice" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/06/27/10-simple-elegant-and-free-wordpress-themes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FreeBSD 8.0 &#8211; Code Freeze &#8211; Whats cooking? Why FreeBSD? Why are you using linux?</title>
		<link>http://grypto.com/2009/06/27/freebsd-8-0-code-freeze-whats-cooking-why-freebsd-why-are-you-using-linux/</link>
		<comments>http://grypto.com/2009/06/27/freebsd-8-0-code-freeze-whats-cooking-why-freebsd-why-are-you-using-linux/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 23:35:21 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[FreeBSD 7]]></category>
		<category><![CDATA[FreeBSD 8]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=33</guid>
		<description><![CDATA[FreeBSD 8.0 – Code freeze [www.evilcoder.org]
In continued preparation to the FreeBSD 8.0 Release, the tree had been frozen by re@. This means that development had been slowed down a lot because everything needs to be reviewed by the Release Engineers first. This step will make sure that the system will get as stable as possible [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.evilcoder.org/2009/06/26/freebsd-8-0-code-freeze/">FreeBSD 8.0 – Code freeze</a> [www.evilcoder.org]</p>
<blockquote><p>In continued preparation to the FreeBSD 8.0 Release, the tree had been frozen by re@. This means that development had been slowed down a lot because everything needs to be reviewed by the Release Engineers first. This step will make sure that the system will get as stable as possible before a fork will be done to RELENG_8. Stay tuned!</p></blockquote>
<p>What's cooking for FreeBSD 8? Plenty. Jails v2, Xen dom-U support, ULE 3.0, and DTrace will all likely make it into the release, not to mention all the other new features, stability and code improvements. What else is cooking in FreeBSD 8? Here is a very long post to pump you up.</p>
<p><a href="http://ivoras.sharanet.org/freebsd/freebsd8.html">FreeBSD - What's cooking for FreeBSD 8?</a> [ivoras.sharanet.org]</p>
<p>Dizzy? Pull yourself together. From <a href="http://en.wikipedia.org/wiki/FreeBSD">Wikipedia</a> [en.wikipedia.org]:</p>
<blockquote><p>As of 2009, FreeBSD 8.0 is the "bleeding edge" development version, called -CURRENT in FreeBSD development terminology. It will feature <a href="http://en.wikipedia.org/wiki/Page_(computing)">superpages</a> [en.wikipedia.org], <a href="http://en.wikipedia.org/wiki/Xen">Xen</a> [en.wikipedia.org] DomU support, network stack virtualization, <a href="http://en.wikipedia.org/wiki/Stack-smashing_protection">stack-smashing protection</a> [en.wikipedia.org], TTY layer rewrite, much improved ZFS support and, new USB stack, and rewritten NFS client/server introducing NFSv4. Inclusion of improved device mmap() extensions will allow the technical implementation of a 64-bit Nvidia display driver for the amd64 platform. FreeBSD 8.0 is planned to be released in the 3rd quarter of 2009.</p></blockquote>
<p>Yahoo! has been using it for years. I have been using it for years. Why FreeBSD? IBM tells you why in 2005.<br />
<a href="http://www.ibm.com/developerworks/opensource/library/os-freebsd/">Why FreeBSD - A quick tour of the BSD alternative</a> [www.ibm.com]</p>
<p>FreeBSD tells you why.<br />
<a href="http://www.freebsd.org/internet.html">About FreeBSD's Internetworking</a> [www.freebsd.org]</p>
<p>FreeBSD made you a slideshow about 7.0 explaining why.<br />
<a href="http://people.freebsd.org/~kris/scaling/7.0%20Preview.pdf">Introducing FreeBSD 7.0</a> [people.freebsd.org]</p>
<p>Right now, you might be feeling anxious. You've been using some linux distro with a name you can't even pronounce or spell properly and a confusing package management system. You thought it was the best. Better than Windows right? You don't know anymore. It doesn't make sense. You're not sure if it ever did make sense. The room starts spinning. You realize this must have been a joke. A Penguin? Some guy named Linus? Ubuntu? Why didn't you see the clues? Is this the real life?</p>
<p>Why are you using linux?</p>
]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/06/27/freebsd-8-0-code-freeze-whats-cooking-why-freebsd-why-are-you-using-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to install Lighttpd, PHP 5, and MySQL 5.1 on FreeBSD 7.2</title>
		<link>http://grypto.com/2009/06/27/how-to-install-lighttpd-php-5-and-mysql-5-1-on-freebsd-7-2/</link>
		<comments>http://grypto.com/2009/06/27/how-to-install-lighttpd-php-5-and-mysql-5-1-on-freebsd-7-2/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 11:39:17 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Lighttpd]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=26</guid>
		<description><![CDATA[Installing MySQL
Before we start, make sure your ports are updated.

portsnap fetch
portsnap update

Right. Now we're ready.

cd /usr/ports/databases/mysql51-server
make install clean

This might take a while. Do something productive.
When that finishes we'll install the database, and make sure user and group mysql is the owner of the database folder.

/usr/local/bin/mysql_install_db
chown -R mysql /var/db/mysql/
chgrp -R mysql /var/db/mysql/

Next, we'll set MySQL to [...]]]></description>
			<content:encoded><![CDATA[<h3>Installing MySQL</h3>
<p>Before we start, make sure your ports are updated.<br />
<code><br />
portsnap fetch<br />
portsnap update<br />
</code></p>
<p>Right. Now we're ready.<br />
<code><br />
cd /usr/ports/databases/mysql51-server<br />
make install clean<br />
</code></p>
<p>This might take a while. Do something productive.</p>
<p>When that finishes we'll install the database, and make sure user and group mysql is the owner of the database folder.<br />
<code><br />
/usr/local/bin/mysql_install_db<br />
chown -R mysql /var/db/mysql/<br />
chgrp -R mysql /var/db/mysql/<br />
</code></p>
<p>Next, we'll set MySQL to start at FreeBSD boot.<br />
<code><br />
echo 'mysql_enable="YES"' >> /etc/rc.conf<br />
</code></p>
<p>Finally, we'll start MySQL and change the root password to keep out the hackers.<br />
<code><br />
/usr/local/etc/rc.d/mysql-server start<br />
/usr/local/bin/mysqladmin -u root password newpassword<br />
</code></p>
<p>If you did everything right, MySQL should now be running.</p>
<h3>Installing Lighttpd</h3>
<p>Assuming our ports are still up to date after that MySQL compile, we'll start the Lighttpd install.<br />
<code><br />
cd /usr/ports/www/lighttpd<br />
make install clean<br />
</code></p>
<p>When that's finished, we'll create the document root folder.<br />
<code><br />
mkdir -p /usr/local/www/data<br />
</code></p>
<p>Now, create the access and error log files. Those files are:<br />
<code><br />
/var/log/lighttpd.access.log<br />
/var/log/lighttpd.error.log<br />
</code></p>
<p>Next, we'll give Lighttpd ownership of it's log files.<br />
<code><br />
chown www:www /var/log/lighttpd.access.log<br />
chown www:www /var/log/lighttpd.error.log<br />
</code></p>
<p>Now it's time to open up the Lighttpd configuration file. Great.<br />
<code><br />
vi /usr/local/etc/lighttpd.conf<br />
</code></p>
<p>Uncomment the line "mod_fastcgi", in "server.modules".</p>
<p>Append the following code in the fastcgi module section.<br />
<code><br />
fastcgi.server = ( ".php" =><br />
( "localhost" =><br />
                     (<br />
                        "socket" => "/tmp/php-fastcgi.socket",<br />
                        "bin-path" => "/usr/local/bin/php-cgi"<br />
                      )<br />
                   )<br />
)<br />
</code></p>
<p>Finally, we'll set Lighttpd to start with FreeBSD.<br />
<code><br />
echo 'lighttpd_enable="YES"' >> /etc/rc.conf<br />
</code></p>
<p>Before we start Lighttpd, Lets install PHP.</p>
<h3>Installing PHP</h3>
<p>Installing PHP is very easy. Ready? Ok.<br />
<code><br />
cd /usr/ports/lang/php5<br />
make install clean<br />
</code></p>
<p>Now we'll install some PHP extensions. Make sure you check the mysql and or mysqli boxes to be able to use MySQL in PHP.<br />
<code><br />
cd /usr/ports/lang/php5-extensions<br />
make config install clean<br />
</code></p>
<p>Next, copy php.ini-recommended to php.ini.<br />
<code><br />
cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini<br />
</code></p>
<p>With PHP installed, we can now start Lighttpd.<br />
<code><br />
/usr/local/etc/rc.d/lighttpd start<br />
</code></p>
<p>It should work now, unless I missed a few steps. Create a phpinfo script in /usr/local/www/data and load it in your browser to test!</p>
]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/06/27/how-to-install-lighttpd-php-5-and-mysql-5-1-on-freebsd-7-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to install MySQL 5.1 on FreeBSD 7.2</title>
		<link>http://grypto.com/2009/06/27/how-to-install-mysql-5-1-on-freebsd-7-2/</link>
		<comments>http://grypto.com/2009/06/27/how-to-install-mysql-5-1-on-freebsd-7-2/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 10:34:59 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=20</guid>
		<description><![CDATA[I've had trouble in the past with installing MySQL on FreeBSD. This is the best method I've used that works.
Before we start, make sure your ports are updated.

portsnap fetch
portsnap update

Right. Now we're ready.

cd /usr/ports/databases/mysql51-server
make install clean

This might take a while. Do something productive.
When that finishes we'll install the database, and make sure user and group [...]]]></description>
			<content:encoded><![CDATA[<p>I've had trouble in the past with installing MySQL on FreeBSD. This is the best method I've used that works.</p>
<p>Before we start, make sure your ports are updated.<br />
<code><br />
portsnap fetch<br />
portsnap update<br />
</code></p>
<p>Right. Now we're ready.<br />
<code><br />
cd /usr/ports/databases/mysql51-server<br />
make install clean<br />
</code></p>
<p>This might take a while. Do something productive.</p>
<p>When that finishes we'll install the database, and make sure user and group mysql is the owner of the database folder.<br />
<code><br />
/usr/local/bin/mysql_install_db<br />
chown -R mysql /var/db/mysql/<br />
chgrp -R mysql /var/db/mysql/<br />
</code></p>
<p>Next, we'll set MySQL to start at FreeBSD boot.<br />
<code><br />
echo 'mysql_enable="YES"' >> /etc/rc.conf<br />
</code></p>
<p>Finally, we'll start MySQL and change the root password to keep out the hackers.<br />
<code><br />
/usr/local/etc/rc.d/mysql-server start<br />
/usr/local/bin/mysqladmin -u root password newpassword<br />
</code></p>
<p>Full code:<br />
<code><br />
cd /usr/ports/databases/mysql51-server<br />
make install clean<br />
/usr/local/bin/mysql_install_db<br />
chown -R mysql /var/db/mysql/<br />
chgrp -R mysql /var/db/mysql/<br />
echo 'mysql_enable="YES"' >> /etc/rc.conf<br />
/usr/local/etc/rc.d/mysql-server start<br />
/usr/local/bin/mysqladmin -u root password newpassword<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/06/27/how-to-install-mysql-5-1-on-freebsd-7-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create a PHP web crawler or scraper in 5 minutes using php-CURL, and php-DOM</title>
		<link>http://grypto.com/2009/06/26/create-a-php-web-crawler-or-scraper-in-5-minutes-using-php-curl-and-php-dom/</link>
		<comments>http://grypto.com/2009/06/26/create-a-php-web-crawler-or-scraper-in-5-minutes-using-php-curl-and-php-dom/#comments</comments>
		<pubDate>Sat, 27 Jun 2009 04:20:23 +0000</pubDate>
		<dc:creator>grypto</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Crawler]]></category>
		<category><![CDATA[crawler]]></category>
		<category><![CDATA[php-curl]]></category>
		<category><![CDATA[php-dom]]></category>

		<guid isPermaLink="false">http://grypto.com/?p=6</guid>
		<description><![CDATA[This post is in response to the articles floating around the internet named, for the most part, "Create a PHP web crawler or scraper in 5 minutes." Here we use PHP DOM and some more complex methods to create "infinitely extendable web crawler in under 5 minutes." Actually it depends on how fast you can read [...]]]></description>
			<content:encoded><![CDATA[<p>This post is in response to the articles floating around the internet named, for the most part, "Create a PHP web crawler or scraper in 5 minutes." Here we use PHP DOM and some more complex methods to create "infinitely extendable web crawler in under 5 minutes." Actually it depends on how fast you can read and copy the code.</p>
<h3>The Framework</h3>
<p>We start with a blank DOM_Crawler class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> DOM_Crawler
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Next, we'll create the methods to fetch, prepare, load into DOM, and collect links.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> DOM_Crawler
<span style="color: #009900;">&#123;</span>
	protected <span style="color: #000088;">$markup</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	protected <span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	protected <span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _load_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _prepare_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$encod</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _init_dom <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _get_links <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _base_url <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Fetching Content</h3>
<p>As in the other examples, the constructor will accept a URL then pass it on to the method "_load_markup()." Php-curl is used here instead of file_get_contents() as file_get_contents() is deprecated in favor of using the CURL libraries. "_prepare_markup()" is then used to fix encoding issues before loading into Php-DOM. "_prepare_markup()" is explained in the comments of <a href="http://us2.php.net/manual/en/domdocument.loadhtml.php">PHP: DOMDocument::loadHTML - Manual</a>. "init_dom()" will initialize Php-DOM.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_base_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_load_markup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_prepare_markup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_init_dom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _load_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$timeout</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000088;">$timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$contents</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _prepare_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$encod</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">mb_detect_order</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ASCII,UTF-8,ISO-8859-1,windows-1252,iso-8859-15&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$encod</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$encod</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_detect_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$headpos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;head&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$headpos</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$headpos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;HEAD&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$headpos</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$headpos</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headpos</span><span style="color: #009900;">&#41;</span> 
<span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$encod</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> 
<span style="color: #339933;">.</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headpos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_convert_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'HTML-ENTITIES'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$encod</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _init_dom <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomDocument<span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">normalizeDocument</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Crawling the Content for Data</h3>
<p>From the other examples: "Our get() method will accept a $type string which essentially will simply be used to invoke another method actually doing the processing. As you can see below we construct the method name as a string, then make sure it is available so now developers can utilize this simply by invoking $crawl->get('images');."</p>
<p>The "_get_links()" will start by fetching all tags named 'a', then it uses DOMElement::getAttribute to return the actual URL from the "href" attribute. If any link lacks the "base" or "scheme, user, password, host, port," we'll fix it by adding $this->base_url. '#' links are simply not included in the array.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;_get_<span style="color: #006699; font-weight: bold;">{$type}</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">method_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">call_user_method</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _get_links <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$anchors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$anchor</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$href</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$anchor</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$href</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base_url</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$href</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$href</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'#'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$href</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$links</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _base_url <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$parsed_url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'scheme'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'://'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'@'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$base_url</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Final Web Crawler Code</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> DOM_Crawler <span style="color: #009900;">&#123;</span>
&nbsp;
	protected <span style="color: #000088;">$markup</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
&nbsp;
	protected <span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	protected <span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_base_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_load_markup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_prepare_markup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_init_dom<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _load_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$timeout</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_setopt</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000088;">$timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$contents</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _prepare_markup <span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$encod</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">mb_detect_order</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ASCII,UTF-8,ISO-8859-1,windows-1252,iso-8859-15&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$encod</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$encod</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_detect_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$headpos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;head&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$headpos</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$headpos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&lt;HEAD&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$headpos</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$headpos</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headpos</span><span style="color: #009900;">&#41;</span> 
<span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$encod</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> 
<span style="color: #339933;">.</span> <span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headpos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mb_convert_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'HTML-ENTITIES'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$encod</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _init_dom <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomDocument<span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">normalizeDocument</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;_get_<span style="color: #006699; font-weight: bold;">{$type}</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">method_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #990000;">call_user_method</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$method</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _get_links <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">markup</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$anchors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$anchor</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$href</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$anchor</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$href</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base_url</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$href</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">mb_substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$href</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'#'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$href</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$links</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> _base_url <span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$parsed_url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">parse_url</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$base_url</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'scheme'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'://'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pass'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'@'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$base_url</span> <span style="color: #339933;">.=</span>  <span style="color: #0000ff;">':'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$parsed_url</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'port'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$base_url</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Usage</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.reddit.com/'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$crawler</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOM_Crawler<span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$links</span> <span style="color: #339933;">=</span> _merge_unique<span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #339933;">,</span> <span style="color: #000088;">$crawler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'links'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$links</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> _merge_unique <span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #339933;">,</span> <span style="color: #000088;">$arr2</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr2</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arr</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Returns:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/funny/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/gaming/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/pics/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/politics/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/programming/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/reddit.com/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/science/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/technology/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/worldnews/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/r/WTF/</span>
    <span style="color: #339933;">.....</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">201</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/help/faq</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">202</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/help/reddiquette</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">203</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/bookmarklets/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">204</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/buttons/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">205</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/code/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">206</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/socialite/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">207</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/widget/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">208</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/iphone/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">209</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/blog/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">210</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//justin.tv/reddit</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">211</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/ad_inq/</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">212</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.tv</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">213</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.redditall.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">214</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.baconbuzz.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">215</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//reddit.destructoid.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">216</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.thecutelist.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">217</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//reddit.independent.co.uk</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">218</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.redditgadgetguide.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">219</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.weheartgossip.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">220</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.idealistnews.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">221</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.wired.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">222</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.arstechnica.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">223</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.style.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">224</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.epicurious.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">225</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.concierge.com</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">226</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//reddit.com/help/useragreement</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">227</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//reddit.com/help/privacypolicy</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">228</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.reddit.com/feedback</span>
<span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://grypto.com/2009/06/26/create-a-php-web-crawler-or-scraper-in-5-minutes-using-php-curl-and-php-dom/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
