<?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>pleech.com &#187; ezinearticles</title>
	<atom:link href="http://pleech.com/tag/ezinearticles/feed/" rel="self" type="application/rss+xml" />
	<link>http://pleech.com</link>
	<description>Online marketing with a twist</description>
	<lastBuildDate>Mon, 06 Sep 2010 14:52:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>EzineArticles scraper</title>
		<link>http://pleech.com/2010/07/ezinearticles-scraper/</link>
		<comments>http://pleech.com/2010/07/ezinearticles-scraper/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 11:57:20 +0000</pubDate>
		<dc:creator>Pigpromoter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[ezinearticles]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[scraping]]></category>

		<guid isPermaLink="false">http://pleech.com/?p=60</guid>
		<description><![CDATA[Piece of code that queries EZA for a given string and grabs an article at random from the first results page. Again, this is slow as fuck and shouldn&#8217;t be used for production sites.

&#60;?php
ini_set('error_reporting', 0);

$scrapeURL		= 'http://ezinearticles.com/search/?q=';
$baseURL		= 'http://ezinearticles.com';
$query			= 'project+management';

$dom = new DOMDocument();
$dom-&#62;loadHTMLFile($scrapeURL . $query);

$divs = $dom-&#62;getElementsByTagName('div');
foreach ($divs as $div) {
	if ($div-&#62;getAttribute('class') == 'srch_title') {
		foreach ($div-&#62;getElementsByTagName('a') as [...]]]></description>
			<content:encoded><![CDATA[<p>Piece of code that queries EZA for a given string and grabs an article at random from the first results page. Again, this is slow as fuck and shouldn&#8217;t be used for production sites.<br />
<span id="more-60"></span></p>
<pre class="brush: php;">&lt;?php
ini_set('error_reporting', 0);

$scrapeURL		= 'http://ezinearticles.com/search/?q=';
$baseURL		= 'http://ezinearticles.com';
$query			= 'project+management';

$dom = new DOMDocument();
$dom-&gt;loadHTMLFile($scrapeURL . $query);

$divs = $dom-&gt;getElementsByTagName('div');
foreach ($divs as $div) {
	if ($div-&gt;getAttribute('class') == 'srch_title') {
		foreach ($div-&gt;getElementsByTagName('a') as $a) {
			$articles[] = $a-&gt;getAttribute('href');
		}
	}
}
$articleURL = $baseURL . $articles[rand(0,count($articles)-1)];

$dom-&gt;loadHTMLFile($articleURL);
$article['title'] 	= $dom-&gt;getElementsByTagName('h1')-&gt;item(0)-&gt;textContent;
$article['body'] = $dom-&gt;getElementById('body')-&gt;textContent;

print &quot;&lt;pre&gt;&quot;;
print_r($article);
print &quot;&lt;/pre&gt;&quot;;

?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://pleech.com/2010/07/ezinearticles-scraper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
