<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: PHP DZone Story Information&#160;Grabber</title> <atom:link href="http://davidwalsh.name/php-dzone-information-grabber/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-dzone-information-grabber</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 19:56:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Alejandro Santos</title><link>http://davidwalsh.name/php-dzone-information-grabber#comment-19362</link> <dc:creator>Alejandro Santos</dc:creator> <pubDate>Fri, 13 Aug 2010 23:05:28 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-dzone-information-grabber/#comment-19362</guid> <description>I added some lines for those who are behind a proxy, also you have an extra on line 8 but this is a good one to track your posts on DZone :)/* step 1: download the page content */
$default_opts = array(‘http’=&gt;array(
‘method’=&gt;”GET”,
‘header’=&gt;”Accept-language: en\r\n” . “Cookie: foo=bar”,
‘proxy’=&gt;”tcp://http-proxy.mycompany.com:80″));
$def = stream_context_get_default($default_opts);
$dzone_content = file_get_contents(‘http://www.dzone.com/links/f_programming_fast_guide.html’);/* step 2: parse it! */
$votes_up = get_match(‘/class=”ldStats-up”&gt;(.*)/isU’, $dzone_content);
$votes_down = get_match(‘/class=”ldStats-down”&gt;(.*)/isU’, $dzone_content);
$views = get_match(‘/(.*)/isU’, $dzone_content);
$clicks = get_match(‘/(.*)/isU’, $dzone_content);/* step 3: echo */
echo ‘Up Votes: ‘,$votes_up,”;
echo ‘Down Votes: ‘,$votes_down,”;
echo ‘Views: ‘,$views,”;
echo ‘Clicks: ‘,$clicks,”;/* helper: does regex */
function get_match($regex, $content){
preg_match($regex, $content, $matches);
return $matches[1];
}</description> <content:encoded><![CDATA[<p>I added some lines for those who are behind a proxy, also you have an extra on line 8 but this is a good one to track your posts on DZone :)</p><p>/* step 1: download the page content */<br
/> $default_opts = array(‘http’=&gt;array(<br
/> ‘method’=&gt;”GET”,<br
/> ‘header’=&gt;”Accept-language: en\r\n” . “Cookie: foo=bar”,<br
/> ‘proxy’=&gt;”tcp://http-proxy.mycompany.com:80″));<br
/> $def = stream_context_get_default($default_opts);<br
/> $dzone_content = file_get_contents(‘http://www.dzone.com/links/f_programming_fast_guide.html’);</p><p>/* step 2: parse it! */<br
/> $votes_up = get_match(‘/class=”ldStats-up”&gt;(.*)/isU’, $dzone_content);<br
/> $votes_down = get_match(‘/class=”ldStats-down”&gt;(.*)/isU’, $dzone_content);<br
/> $views = get_match(‘/(.*)/isU’, $dzone_content);<br
/> $clicks = get_match(‘/(.*)/isU’, $dzone_content);</p><p>/* step 3: echo */<br
/> echo ‘Up Votes: ‘,$votes_up,”;<br
/> echo ‘Down Votes: ‘,$votes_down,”;<br
/> echo ‘Views: ‘,$views,”;<br
/> echo ‘Clicks: ‘,$clicks,”;</p><p>/* helper: does regex */<br
/> function get_match($regex, $content){<br
/> preg_match($regex, $content, $matches);<br
/> return $matches[1];<br
/> }</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.006 seconds using disk: basic
Object Caching 282/282 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 16:11:33 -->
