<?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>Giv Parvaneh &#187; PHP</title>
	<atom:link href="http://www.givp.org/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.givp.org/blog</link>
	<description>::::..::..:::::::...:::::....::......:::::::::....::::......::::::::::::::::</description>
	<lastBuildDate>Thu, 22 Jul 2010 21:42:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex,follow" />
		<item>
		<title>Test-driven Development in Agile Projects</title>
		<link>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/</link>
		<comments>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 14:29:06 +0000</pubDate>
		<dc:creator>Giv</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.givp.org/blog/?p=113</guid>
		<description><![CDATA[I recently posted this on the BBC Web Developer Blog: http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml Developers at the BBC tend to use Agile methodologies as a way to quickly release iterations of products. But where does rigorous code testing fit in with the short development and release cycles? How can we maintain the quality of our code when things [...]]]></description>
			<content:encoded><![CDATA[<p>I recently posted this on the BBC Web Developer Blog:</p>
<p><a href="http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml" onclick="pageTracker._trackPageview('/outgoing/www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml?referer=');">http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml</a></p>
<blockquote><p>
Developers at the BBC tend to use Agile methodologies as a way to quickly release iterations of products. But where does rigorous code testing fit in with the short development and release cycles? How can we maintain the quality of our code when things need to change so fast?
</p></blockquote>
<p><a href="http://www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml" onclick="pageTracker._trackPageview('/outgoing/www.bbc.co.uk/blogs/webdeveloper/2009/11/testdriven-development-in-agil.shtml?referer=');">More</a></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://twitter.com/home?status=Test-driven%20Development%20in%20Agile%20Projects%20-%20http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F11%2F21%2Ftest-driven-development-in-agile%2F" title="Twitter" onclick="pageTracker._trackPageview('/outgoing/twitter.com/home?status=Test-driven_20Development_20in_20Agile_20Projects_20-_20http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F11_2F21_2Ftest-driven-development-in-agile_2F&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F11%2F21%2Ftest-driven-development-in-agile%2F&amp;t=Test-driven%20Development%20in%20Agile%20Projects" title="Facebook" onclick="pageTracker._trackPageview('/outgoing/www.facebook.com/share.php?u=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F11_2F21_2Ftest-driven-development-in-agile_2F_amp_t=Test-driven_20Development_20in_20Agile_20Projects&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F11%2F21%2Ftest-driven-development-in-agile%2F&amp;title=Test-driven%20Development%20in%20Agile%20Projects&amp;bodytext=I%20recently%20posted%20this%20on%20the%20BBC%20Web%20Developer%20Blog%3A%0A%0Ahttp%3A%2F%2Fwww.bbc.co.uk%2Fblogs%2Fwebdeveloper%2F2009%2F11%2Ftestdriven-development-in-agil.shtml%0A%0A%0ADevelopers%20at%20the%20BBC%20tend%20to%20use%20Agile%20methodologies%20as%20a%20way%20to%20quickly%20release%20iterations%20of%20products.%20Bu" title="Digg" onclick="pageTracker._trackPageview('/outgoing/digg.com/submit?phase=2_amp_url=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F11_2F21_2Ftest-driven-development-in-agile_2F_amp_title=Test-driven_20Development_20in_20Agile_20Projects_amp_bodytext=I_20recently_20posted_20this_20on_20the_20BBC_20Web_20Developer_20Blog_3A_0A_0Ahttp_3A_2F_2Fwww.bbc.co.uk_2Fblogs_2Fwebdeveloper_2F2009_2F11_2Ftestdriven-development-in-agil.shtml_0A_0A_0ADevelopers_20at_20the_20BBC_20tend_20to_20use_20Agile_20methodologies_20as_20a_20way_20to_20quickly_20release_20iterations_20of_20products._20Bu&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F11%2F21%2Ftest-driven-development-in-agile%2F&amp;title=Test-driven%20Development%20in%20Agile%20Projects&amp;notes=I%20recently%20posted%20this%20on%20the%20BBC%20Web%20Developer%20Blog%3A%0A%0Ahttp%3A%2F%2Fwww.bbc.co.uk%2Fblogs%2Fwebdeveloper%2F2009%2F11%2Ftestdriven-development-in-agil.shtml%0A%0A%0ADevelopers%20at%20the%20BBC%20tend%20to%20use%20Agile%20methodologies%20as%20a%20way%20to%20quickly%20release%20iterations%20of%20products.%20Bu" title="del.icio.us" onclick="pageTracker._trackPageview('/outgoing/delicious.com/post?url=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F11_2F21_2Ftest-driven-development-in-agile_2F_amp_title=Test-driven_20Development_20in_20Agile_20Projects_amp_notes=I_20recently_20posted_20this_20on_20the_20BBC_20Web_20Developer_20Blog_3A_0A_0Ahttp_3A_2F_2Fwww.bbc.co.uk_2Fblogs_2Fwebdeveloper_2F2009_2F11_2Ftestdriven-development-in-agil.shtml_0A_0A_0ADevelopers_20at_20the_20BBC_20tend_20to_20use_20Agile_20methodologies_20as_20a_20way_20to_20quickly_20release_20iterations_20of_20products._20Bu&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F11%2F21%2Ftest-driven-development-in-agile%2F&amp;title=Test-driven%20Development%20in%20Agile%20Projects&amp;annotation=I%20recently%20posted%20this%20on%20the%20BBC%20Web%20Developer%20Blog%3A%0A%0Ahttp%3A%2F%2Fwww.bbc.co.uk%2Fblogs%2Fwebdeveloper%2F2009%2F11%2Ftestdriven-development-in-agil.shtml%0A%0A%0ADevelopers%20at%20the%20BBC%20tend%20to%20use%20Agile%20methodologies%20as%20a%20way%20to%20quickly%20release%20iterations%20of%20products.%20Bu" title="Google Bookmarks" onclick="pageTracker._trackPageview('/outgoing/www.google.com/bookmarks/mark?op=edit_amp_bkmk=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F11_2F21_2Ftest-driven-development-in-agile_2F_amp_title=Test-driven_20Development_20in_20Agile_20Projects_amp_annotation=I_20recently_20posted_20this_20on_20the_20BBC_20Web_20Developer_20Blog_3A_0A_0Ahttp_3A_2F_2Fwww.bbc.co.uk_2Fblogs_2Fwebdeveloper_2F2009_2F11_2Ftestdriven-development-in-agil.shtml_0A_0A_0ADevelopers_20at_20the_20BBC_20tend_20to_20use_20Agile_20methodologies_20as_20a_20way_20to_20quickly_20release_20iterations_20of_20products._20Bu&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.givp.org/blog/2009/11/21/test-driven-development-in-agile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Scraping &#8211; Python vs PHP (re-post)</title>
		<link>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/</link>
		<comments>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:11:19 +0000</pubDate>
		<dc:creator>Giv</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.givp.org/blog/?p=81</guid>
		<description><![CDATA[I posted this last year on my old blog. The subject came up again today so I dug it up from the archives: I usually hate these &#8220;X vs Y&#8221; discussions but this week I was working on a harvesting project and was trying to figure out whether I should go down the Python or [...]]]></description>
			<content:encoded><![CDATA[<p>I posted this last year on my old blog. The subject came up again today so I dug it up from the archives:</p>
<p>I usually hate these &#8220;X vs Y&#8221; discussions but this week I was working on a harvesting project and was trying to figure out whether I should go down the Python or PHP route. I have been using PHP for many years now so PHP was the obvious choice but recently I have been using Python a fair bit and the more I use it, the more I realise what a sloppy language PHP is.</p>
<p>So I set out to do some tests to see which would get my task done quicker.</p>
<p>For Python I used the <a href="http://www.crummy.com/software/BeautifulSoup/" onclick="pageTracker._trackPageview('/outgoing/www.crummy.com/software/BeautifulSoup/?referer=');">Beautiful Soup</a> module and for PHP I used <a href="http://simplehtmldom.sourceforge.net/" onclick="pageTracker._trackPageview('/outgoing/simplehtmldom.sourceforge.net/?referer=');">PHP Simple HTML DOM Parser</a> class.</p>
<p><strong>The test:</strong><br />
<em>Go to http://news.bbc.co.uk, look for the third &lt;p&gt; tag and return the text for the first link within that paragraph.</em></p>
<p>Both classes make this very easy to do so coding was not a concern:</p>
<p><strong>in Python:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">page = <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://news.bbc.co.uk&quot;</span><span style="color: black;">&#41;</span>
soup = BeautifulSoup<span style="color: black;">&#40;</span>page<span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> soup.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'p'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>.<span style="color: black;">findAll</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'a'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>.<span style="color: #dc143c;">string</span></pre></td></tr></table></div>

<p><strong>in PHP:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> file_get_html<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://news.bbc.co.uk'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'p'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">innertext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>I ran each 5 times to measure the execution time.</p>
<p><strong>Python:</strong><br />
0.622022151947 seconds<br />
0.577415943146 seconds<br />
0.518396139145 seconds<br />
0.503247022629 seconds<br />
0.482849121094 seconds</p>
<p><strong>PHP:</strong><br />
0.430239915848 seconds<br />
0.415632009506 seconds<br />
0.408473014832 seconds<br />
0.413187026978 seconds<br />
0.411664962769 seconds</p>
<p>Pretty damn close but PHP is on average a bit faster it seems.</p>
<p>To be fair, this really isn&#8217;t a very good way to measure the performance of the two. The real test, in my opinion, would be to see how scalable each method is and how they handle memory management once I start scraping say the entire Wikipedia collection. I could be wrong here but from what I&#8217;ve read so far, Python is the tool of choice for such heavy processing tasks.</p>
<p>Either way, I think I&#8217;ll go with Python <img src='http://www.givp.org/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://twitter.com/home?status=HTML%20Scraping%20-%20Python%20vs%20PHP%20%28re-post%29%20-%20http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F10%2F26%2Fhtml-scraping-python-vs-php%2F" title="Twitter" onclick="pageTracker._trackPageview('/outgoing/twitter.com/home?status=HTML_20Scraping_20-_20Python_20vs_20PHP_20_28re-post_29_20-_20http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F10_2F26_2Fhtml-scraping-python-vs-php_2F&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F10%2F26%2Fhtml-scraping-python-vs-php%2F&amp;t=HTML%20Scraping%20-%20Python%20vs%20PHP%20%28re-post%29" title="Facebook" onclick="pageTracker._trackPageview('/outgoing/www.facebook.com/share.php?u=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F10_2F26_2Fhtml-scraping-python-vs-php_2F_amp_t=HTML_20Scraping_20-_20Python_20vs_20PHP_20_28re-post_29&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F10%2F26%2Fhtml-scraping-python-vs-php%2F&amp;title=HTML%20Scraping%20-%20Python%20vs%20PHP%20%28re-post%29&amp;bodytext=I%20posted%20this%20last%20year%20on%20my%20old%20blog.%20The%20subject%20came%20up%20again%20today%20so%20I%20dug%20it%20up%20from%20the%20archives%3A%0A%0AI%20usually%20hate%20these%20%22X%20vs%20Y%22%20discussions%20but%20this%20week%20I%20was%20working%20on%20a%20harvesting%20project%20and%20was%20trying%20to%20figure%20out%20whether%20I%20should%20go%20" title="Digg" onclick="pageTracker._trackPageview('/outgoing/digg.com/submit?phase=2_amp_url=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F10_2F26_2Fhtml-scraping-python-vs-php_2F_amp_title=HTML_20Scraping_20-_20Python_20vs_20PHP_20_28re-post_29_amp_bodytext=I_20posted_20this_20last_20year_20on_20my_20old_20blog._20The_20subject_20came_20up_20again_20today_20so_20I_20dug_20it_20up_20from_20the_20archives_3A_0A_0AI_20usually_20hate_20these_20_22X_20vs_20Y_22_20discussions_20but_20this_20week_20I_20was_20working_20on_20a_20harvesting_20project_20and_20was_20trying_20to_20figure_20out_20whether_20I_20should_20go_20&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F10%2F26%2Fhtml-scraping-python-vs-php%2F&amp;title=HTML%20Scraping%20-%20Python%20vs%20PHP%20%28re-post%29&amp;notes=I%20posted%20this%20last%20year%20on%20my%20old%20blog.%20The%20subject%20came%20up%20again%20today%20so%20I%20dug%20it%20up%20from%20the%20archives%3A%0A%0AI%20usually%20hate%20these%20%22X%20vs%20Y%22%20discussions%20but%20this%20week%20I%20was%20working%20on%20a%20harvesting%20project%20and%20was%20trying%20to%20figure%20out%20whether%20I%20should%20go%20" title="del.icio.us" onclick="pageTracker._trackPageview('/outgoing/delicious.com/post?url=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F10_2F26_2Fhtml-scraping-python-vs-php_2F_amp_title=HTML_20Scraping_20-_20Python_20vs_20PHP_20_28re-post_29_amp_notes=I_20posted_20this_20last_20year_20on_20my_20old_20blog._20The_20subject_20came_20up_20again_20today_20so_20I_20dug_20it_20up_20from_20the_20archives_3A_0A_0AI_20usually_20hate_20these_20_22X_20vs_20Y_22_20discussions_20but_20this_20week_20I_20was_20working_20on_20a_20harvesting_20project_20and_20was_20trying_20to_20figure_20out_20whether_20I_20should_20go_20&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.givp.org%2Fblog%2F2009%2F10%2F26%2Fhtml-scraping-python-vs-php%2F&amp;title=HTML%20Scraping%20-%20Python%20vs%20PHP%20%28re-post%29&amp;annotation=I%20posted%20this%20last%20year%20on%20my%20old%20blog.%20The%20subject%20came%20up%20again%20today%20so%20I%20dug%20it%20up%20from%20the%20archives%3A%0A%0AI%20usually%20hate%20these%20%22X%20vs%20Y%22%20discussions%20but%20this%20week%20I%20was%20working%20on%20a%20harvesting%20project%20and%20was%20trying%20to%20figure%20out%20whether%20I%20should%20go%20" title="Google Bookmarks" onclick="pageTracker._trackPageview('/outgoing/www.google.com/bookmarks/mark?op=edit_amp_bkmk=http_3A_2F_2Fwww.givp.org_2Fblog_2F2009_2F10_2F26_2Fhtml-scraping-python-vs-php_2F_amp_title=HTML_20Scraping_20-_20Python_20vs_20PHP_20_28re-post_29_amp_annotation=I_20posted_20this_20last_20year_20on_20my_20old_20blog._20The_20subject_20came_20up_20again_20today_20so_20I_20dug_20it_20up_20from_20the_20archives_3A_0A_0AI_20usually_20hate_20these_20_22X_20vs_20Y_22_20discussions_20but_20this_20week_20I_20was_20working_20on_20a_20harvesting_20project_20and_20was_20trying_20to_20figure_20out_20whether_20I_20should_20go_20&amp;referer=');"><img src="http://www.givp.org/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.givp.org/blog/2009/10/26/html-scraping-python-vs-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
