<?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/"
		>
<channel>
	<title>Comments on: Executing multiple curl requests in parallel with PHP and curl_multi_exec</title>
	<atom:link href="http://www.rustyrazorblade.com/2008/02/curl_multi_exec/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<lastBuildDate>Mon, 23 Jan 2012 09:03:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Andrew</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-87230</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Mon, 05 Dec 2011 21:09:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-87230</guid>
		<description>You have a problem in the loop calling curl_multi_exec(). You need to either introduce a call to usleep() or curl_multi_select() to prevent PHP from just endlessly calling curl_multi_exec() and eating up all available CPU time. If you make a request that will take a long time to complete you can see this happening just by watching the output of top. Preferably you should use curl_multi_select() after you stop receiving CURLM_CALL_MULTI_PERFORM from curl_multi_exec(). Basically what this does is prevent PHP from calling curl_multi_exec() before you&#039;ve gotten data back from one of the requests so instead of calling it 1000x a second while you&#039;re waiting on network I/O it&#039;ll just wait for the network I/O to complete before it calls curl_multi_exec() because nothing could have possibly changed before curl_multi_select() returns. I hope I made this clear enough, right now your script just sits around using %100 CPU time while waiting for a response. There&#039;s no need for it when you can just sleep until there&#039;s some change to the status of the multi handle.</description>
		<content:encoded><![CDATA[<p>You have a problem in the loop calling curl_multi_exec(). You need to either introduce a call to usleep() or curl_multi_select() to prevent PHP from just endlessly calling curl_multi_exec() and eating up all available CPU time. If you make a request that will take a long time to complete you can see this happening just by watching the output of top. Preferably you should use curl_multi_select() after you stop receiving CURLM_CALL_MULTI_PERFORM from curl_multi_exec(). Basically what this does is prevent PHP from calling curl_multi_exec() before you&#8217;ve gotten data back from one of the requests so instead of calling it 1000x a second while you&#8217;re waiting on network I/O it&#8217;ll just wait for the network I/O to complete before it calls curl_multi_exec() because nothing could have possibly changed before curl_multi_select() returns. I hope I made this clear enough, right now your script just sits around using %100 CPU time while waiting for a response. There&#8217;s no need for it when you can just sleep until there&#8217;s some change to the status of the multi handle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stu</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-85841</link>
		<dc:creator>Stu</dc:creator>
		<pubDate>Sun, 27 Nov 2011 23:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-85841</guid>
		<description>I was wondering what kind of techniques you guys are using for mining the data retreived? I have built an array of urls, then retreive the pages using curl_multi_getcontent, writing the content to an array then mining the array, appending new lines with the extracted data I want BUT have started to run into memory issues.  

Am I approaching this all wrong?</description>
		<content:encoded><![CDATA[<p>I was wondering what kind of techniques you guys are using for mining the data retreived? I have built an array of urls, then retreive the pages using curl_multi_getcontent, writing the content to an array then mining the array, appending new lines with the extracted data I want BUT have started to run into memory issues.  </p>
<p>Am I approaching this all wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jon</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-83253</link>
		<dc:creator>jon</dc:creator>
		<pubDate>Thu, 10 Nov 2011 06:00:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-83253</guid>
		<description>Stu, I don&#039;t see why not.  Looking at the docs I saw this:

// Create a DOM object from a string
$html = str_get_html(&#039;&lt;html&gt;&lt;body&gt;Hello!&lt;/body&gt;&lt;/html&gt;&#039;);

That seems like it&#039;ll do the trick.</description>
		<content:encoded><![CDATA[<p>Stu, I don&#8217;t see why not.  Looking at the docs I saw this:</p>
<p>// Create a DOM object from a string<br />
$html = str_get_html(&#8216;<html><body>Hello!</body></html>&#8216;);</p>
<p>That seems like it&#8217;ll do the trick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stu</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-83210</link>
		<dc:creator>Stu</dc:creator>
		<pubDate>Wed, 09 Nov 2011 20:25:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-83210</guid>
		<description>This article was a pleasure to read, thank you all so much for the additional comments, examples and links.

I have been using the Simple HTML DOM Parser requesting pages with file_get_html.  I am finding it to be good, but slower than I would like it to be, so when I finally found this article about processing multiple requests in parallel I was excited.

My experience with the extracting the information I want from each page took me to using the Simple HTML DOM Parser as it seemed a great deal more tolerant than other methods.

Can I mix the usage of curl_multi_getcontent and the Simple HTML DOM Parser or is that just insaine?  I am new to scraping with PHP (Can you tell?)</description>
		<content:encoded><![CDATA[<p>This article was a pleasure to read, thank you all so much for the additional comments, examples and links.</p>
<p>I have been using the Simple HTML DOM Parser requesting pages with file_get_html.  I am finding it to be good, but slower than I would like it to be, so when I finally found this article about processing multiple requests in parallel I was excited.</p>
<p>My experience with the extracting the information I want from each page took me to using the Simple HTML DOM Parser as it seemed a great deal more tolerant than other methods.</p>
<p>Can I mix the usage of curl_multi_getcontent and the Simple HTML DOM Parser or is that just insaine?  I am new to scraping with PHP (Can you tell?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayjay</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-75251</link>
		<dc:creator>jayjay</dc:creator>
		<pubDate>Tue, 23 Aug 2011 02:42:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-75251</guid>
		<description>Maybe third time lucky ;)~

&#047;/=====&#061;&#061;=&#061;&#061;=&#061;&#061;&#061;=&#061;&#061;&#061;=&#061;&#061;===&#061;=&#061;&#061;&#061;=&#061;&#061;==&#061;==&#061;&#061;=&#061;=====&#061;====
&#035;P&#097;g&#101;&#076;&#111;ad &#084;i&#109;&#101;&#114;&#058; P&#097;&#114;&#116; &#065; (&#084;op &#115;&#101;gme&#110;t&#041;
$&#115;ta&#114;ttime &#061; mic&#114;&#111;&#116;im&#101;(&#041;;
&#036;&#115;tartarr&#097;&#121; = &#101;&#120;&#112;&#108;&#111;de(&quot; &quot;, &#036;&#115;&#116;arttime);
&#036;&#115;&#116;&#097;rtt&#105;&#109;&#101; &#061; &#036;s&#116;a&#114;ta&#114;&#114;a&#121;&#091;&#049;&#093;+&#036;&#115;ta&#114;&#116;a&#114;r&#097;y&#091;0];
/&#047;=&#061;=&#061;&#061;&#061;===&#061;=&#061;&#061;===&#061;&#061;====&#061;==&#061;==&#061;===&#061;&#061;&#061;==&#061;===&#061;&#061;&#061;&#061;&#061;&#061;&#061;=&#061;&#061;

$n&#111;&#100;es &#061; &#097;&#114;&#114;ay&#040;
&quot;&#104;t&#116;&#112;:&#047;/w&#119;&#119;.&#105;&#097;n&#097;&#046;&#111;rg&#047;do&#109;ains/e&#120;&#097;&#109;&#112;l&#101;/&quot;,
&quot;&#104;t&#116;&#112;&#058;//&#119;ww&#046;&#112;&#104;p&#046;n&#101;&#116;/&quot;,
&quot;ht&#116;p&#058;&#047;/&#119;w&#119;&#046;se&#097;rch.&#099;o&#109;&quot;&#044;
&quot;&#104;&#116;tp&#058;//a&#099;.c&#111;&#109;&#047;&quot;, 
&quot;h&#116;&#116;&#112;&#058;&#047;/w&#119;w.g&#111;&#111;l&#101;.com&#047;&quot;&#044;
&quot;&#104;&#116;&#116;p&#058;&#047;/&#097;&#100;&#046;&#099;om/&quot;&#044; 
&quot;&#104;&#116;&#116;p://ww&#119;.ph&#112;c&#111;d&#101;&#114;&#115;.&#099;&#111;m/&quot;&#044;
&quot;h&#116;&#116;&#112;&#058;/&#047;&#119;&#119;w.&#097;h&#046;c&#111;&#109;&#047;&quot;,
&quot;ht&#116;p://w&#119;w&#046;ja&#118;&#097;c&#111;d&#101;rs.com&#047;&quot;,
&quot;ht&#116;p:/&#047;&#119;&#119;&#119;&#046;ru&#115;ty&#114;a&#122;&#111;r&#098;&#108;ad&#101;&#046;&#099;om/&quot;&#044;
&quot;ht&#116;p://www.&#097;l.c&#111;&#109;/&quot;,
&quot;&#104;&#116;&#116;p&#058;&#047;/ww&#119;&#046;car&#115;&#046;c&#111;&#109;&#047;&quot;&#041;&#059;

$n&#111;de&#095;cou&#110;&#116; = c&#111;&#117;&#110;&#116;($no&#100;es);
$&#099;u&#114;&#108;_&#097;&#114;r = &#097;&#114;&#114;&#097;&#121;&#040;&#041;;
&#036;m&#097;ste&#114; &#061; &#099;u&#114;l_&#109;ult&#105;&#095;i&#110;it(&#041;;
&#102;o&#114;($&#105;=&#048;; $&#105;0)&#059;
e&#099;ho &quot;RE&#083;ULTS&#058;&quot;&#059;
for($i&#061;0; &#036;i&lt;$node_count; $i++) {
	$results = curl_multi_getcontent($curl_arr[$i]);
	$start = strpos($results,&quot;&quot;&#041;;
    $en&#100; = s&#116;r&#112;os(&#036;&#114;es&#117;&#108;&#116;s&#044;&quot;&quot;,$start);
    $titles = substr($results, $start, $end-$start);
echo &quot;Titles: &#124;&quot;, trim(strip_tags(str_replace(&quot;\n&quot;, &quot;&quot;, $titles))), &quot;&#124;&quot;;
}

//===================================================
#PageLoad Timer: Part B (Bottom segment – output):

echo &quot;============================================================&quot;;
$endtime = microtime();
$endarray = explode(&quot; &quot;, $endtime);
$endtime = $endarray[1]+$endarray[0];
$totaltime = $endtime-$starttime;
$totaltime = round($totaltime,6);
echo &quot;Pageload time took $totaltime seconds.&quot;.PHP_EOL;
echo&quot;============================================================&quot;;


enjoy~ :)</description>
		<content:encoded><![CDATA[<p>Maybe third time lucky <img src='http://www.rustyrazorblade.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ~</p>
<p>&#047;/=====&#061;&#061;=&#061;&#061;=&#061;&#061;&#061;=&#061;&#061;&#061;=&#061;&#061;===&#061;=&#061;&#061;&#061;=&#061;&#061;==&#061;==&#061;&#061;=&#061;=====&#061;====<br />
&#035;P&#097;g&#101;&#076;&#111;ad &#084;i&#109;&#101;&#114;&#058; P&#097;&#114;&#116; &#065; (&#084;op &#115;&#101;gme&#110;t&#041;<br />
$&#115;ta&#114;ttime &#061; mic&#114;&#111;&#116;im&#101;(&#041;;<br />
&#036;&#115;tartarr&#097;&#121; = &#101;&#120;&#112;&#108;&#111;de(&#8221; &#8220;, &#036;&#115;&#116;arttime);<br />
&#036;&#115;&#116;&#097;rtt&#105;&#109;&#101; &#061; &#036;s&#116;a&#114;ta&#114;&#114;a&#121;&#091;&#049;&#093;+&#036;&#115;ta&#114;&#116;a&#114;r&#097;y&#091;0];<br />
/&#047;=&#061;=&#061;&#061;&#061;===&#061;=&#061;&#061;===&#061;&#061;====&#061;==&#061;==&#061;===&#061;&#061;&#061;==&#061;===&#061;&#061;&#061;&#061;&#061;&#061;&#061;=&#061;&#061;</p>
<p>$n&#111;&#100;es &#061; &#097;&#114;&#114;ay&#040;<br />
&#8220;&#104;t&#116;&#112;:&#047;/w&#119;&#119;.&#105;&#097;n&#097;&#046;&#111;rg&#047;do&#109;ains/e&#120;&#097;&#109;&#112;l&#101;/&#8221;,<br />
&#8220;&#104;t&#116;&#112;&#058;//&#119;ww&#046;&#112;&#104;p&#046;n&#101;&#116;/&#8221;,<br />
&#8220;ht&#116;p&#058;&#047;/&#119;w&#119;&#046;se&#097;rch.&#099;o&#109;&#8221;&#044;<br />
&#8220;&#104;&#116;tp&#058;//a&#099;.c&#111;&#109;&#047;&#8221;,<br />
&#8220;h&#116;&#116;&#112;&#058;&#047;/w&#119;w.g&#111;&#111;l&#101;.com&#047;&#8221;&#044;<br />
&#8220;&#104;&#116;&#116;p&#058;&#047;/&#097;&#100;&#046;&#099;om/&#8221;&#044;<br />
&#8220;&#104;&#116;&#116;p://ww&#119;.ph&#112;c&#111;d&#101;&#114;&#115;.&#099;&#111;m/&#8221;&#044;<br />
&#8220;h&#116;&#116;&#112;&#058;/&#047;&#119;&#119;w.&#097;h&#046;c&#111;&#109;&#047;&#8221;,<br />
&#8220;ht&#116;p://w&#119;w&#046;ja&#118;&#097;c&#111;d&#101;rs.com&#047;&#8221;,<br />
&#8220;ht&#116;p:/&#047;&#119;&#119;&#119;&#046;ru&#115;ty&#114;a&#122;&#111;r&#098;&#108;ad&#101;&#046;&#099;om/&#8221;&#044;<br />
&#8220;ht&#116;p://www.&#097;l.c&#111;&#109;/&#8221;,<br />
&#8220;&#104;&#116;&#116;p&#058;&#047;/ww&#119;&#046;car&#115;&#046;c&#111;&#109;&#047;&#8221;&#041;&#059;</p>
<p>$n&#111;de&#095;cou&#110;&#116; = c&#111;&#117;&#110;&#116;($no&#100;es);<br />
$&#099;u&#114;&#108;_&#097;&#114;r = &#097;&#114;&#114;&#097;&#121;&#040;&#041;;<br />
&#036;m&#097;ste&#114; &#061; &#099;u&#114;l_&#109;ult&#105;&#095;i&#110;it(&#041;;<br />
&#102;o&#114;($&#105;=&#048;; $&#105;0)&#059;<br />
e&#099;ho &#8220;RE&#083;ULTS&#058;&#8221;&#059;<br />
for($i&#061;0; &#036;i&lt;$node_count; $i++) {<br />
	$results = curl_multi_getcontent($curl_arr[$i]);<br />
	$start = strpos($results,&quot;&#8221;&#041;;<br />
    $en&#100; = s&#116;r&#112;os(&#036;&#114;es&#117;&#108;&#116;s&#044;&#8221;",$start);<br />
    $titles = substr($results, $start, $end-$start);<br />
echo &#8220;Titles: |&#8221;, trim(strip_tags(str_replace(&#8220;\n&#8221;, &#8220;&#8221;, $titles))), &#8220;|&#8221;;<br />
}</p>
<p>//===================================================<br />
#PageLoad Timer: Part B (Bottom segment – output):</p>
<p>echo &#8220;============================================================&#8221;;<br />
$endtime = microtime();<br />
$endarray = explode(&#8221; &#8220;, $endtime);<br />
$endtime = $endarray[1]+$endarray[0];<br />
$totaltime = $endtime-$starttime;<br />
$totaltime = round($totaltime,6);<br />
echo &#8220;Pageload time took $totaltime seconds.&#8221;.PHP_EOL;<br />
echo&#8221;============================================================&#8221;;</p>
<p>enjoy~ <img src='http://www.rustyrazorblade.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayjay</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-75248</link>
		<dc:creator>jayjay</dc:creator>
		<pubDate>Tue, 23 Aug 2011 02:28:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-75248</guid>
		<description>$node_count = count($nodes);
$curl_arr = array();
$master = curl_multi_init();
for($i=0; $i0);
echo &quot;RESULTS:&quot;;
for($i=0; $i&lt;$node_count; $i++) {
	$results = curl_multi_getcontent($curl_arr[$i]);
	$start = strpos($results,&quot;&quot;);
    $end = strpos($results,&quot;&quot;,$start);
    $titles = substr($results, $start, $end-$start);
echo &quot;Titles: &#124;&quot;, trim(strip_tags(str_replace(&quot;\n&quot;, &quot;&quot;, $titles))), &quot;&#124;&quot;;
}</description>
		<content:encoded><![CDATA[<p>$node_count = count($nodes);<br />
$curl_arr = array();<br />
$master = curl_multi_init();<br />
for($i=0; $i0);<br />
echo &#8220;RESULTS:&#8221;;<br />
for($i=0; $i&lt;$node_count; $i++) {<br />
	$results = curl_multi_getcontent($curl_arr[$i]);<br />
	$start = strpos($results,&quot;&#8221;);<br />
    $end = strpos($results,&#8221;",$start);<br />
    $titles = substr($results, $start, $end-$start);<br />
echo &#8220;Titles: |&#8221;, trim(strip_tags(str_replace(&#8220;\n&#8221;, &#8220;&#8221;, $titles))), &#8220;|&#8221;;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayjay</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-75247</link>
		<dc:creator>jayjay</dc:creator>
		<pubDate>Tue, 23 Aug 2011 02:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-75247</guid>
		<description>@DarkCoder [..]Both my above samples are displayed wrong. There seem to be a problem here posting code.[..]
codes posted on wordpress blogs (like this one ;) ) are salted to prevent them executing. When coping code from the examples double and single quotes need to be replaced with their genuine ASCII counterparts. Your code has issues too here: for($i = 0; $i 0); needs to be fixed and the usage of regular expressions for title matching is greedy on time and resources. Here&#039;s a better way to to it (though just as crude - example proposes only ;) )

//===================================================
#PageLoad Timer: Part A (Top segment) 
$starttime = microtime();
$startarray = explode(&quot; &quot;, $starttime);
$starttime = $startarray[1]+$startarray[0];
//===================================================

$nodes = array(
&quot;http://www.rustyrazorblade.com/&quot;,
&quot;http://www.iana.org/domains/example/&quot;,
&quot;http://www.php.net/&quot;,
&quot;http://www.search.com&quot;,
&quot;http://ac.com/&quot;, 
&quot;http://www.goole.com/&quot;,
&quot;http://ad.com/&quot;, 
&quot;http://www.phpcoders.com/&quot;,
&quot;http://www.ah.com/&quot;,
&quot;http://www.javacoders.com/&quot;,
&quot;http://www.al.com/&quot;,
&quot;http://www.cars.com/&quot;);

$node_count = count($nodes);
$curl_arr = array();
$master = curl_multi_init();
for($i=0; $i0);
echo &quot;RESULTS:&quot;;
for($i=0; $i&lt;$node_count; $i++) {
	$results = curl_multi_getcontent($curl_arr[$i]);
	$start = strpos($results, &quot;&quot;);
        $end = strpos($results, &quot;&quot;, $start);
        $titles = substr($results, $start, $end-$start);
echo &quot;Titles: &#124;&quot;, trim(strip_tags(str_replace(&quot;\n&quot;, &quot;&quot;, $titles))), &quot;&#124;&quot;;
}


//===================================================
#PageLoad Timer: Part B (Bottom segment - output):

echo &quot;============================================================&quot;;
$endtime = microtime();
$endarray = explode(&quot; &quot;, $endtime);
$endtime = $endarray[1]+$endarray[0];
$totaltime = $endtime-$starttime;
$totaltime = round($totaltime,6);
echo &quot;Pageload time took $totaltime seconds.&quot;.PHP_EOL;
echo &quot;============================================================&quot;;


enjoy :)</description>
		<content:encoded><![CDATA[<p>@DarkCoder [..]Both my above samples are displayed wrong. There seem to be a problem here posting code.[..]<br />
codes posted on wordpress blogs (like this one <img src='http://www.rustyrazorblade.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) are salted to prevent them executing. When coping code from the examples double and single quotes need to be replaced with their genuine ASCII counterparts. Your code has issues too here: for($i = 0; $i 0); needs to be fixed and the usage of regular expressions for title matching is greedy on time and resources. Here&#8217;s a better way to to it (though just as crude &#8211; example proposes only <img src='http://www.rustyrazorblade.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>//===================================================<br />
#PageLoad Timer: Part A (Top segment)<br />
$starttime = microtime();<br />
$startarray = explode(&#8221; &#8220;, $starttime);<br />
$starttime = $startarray[1]+$startarray[0];<br />
//===================================================</p>
<p>$nodes = array(<br />
&#8220;http://www.rustyrazorblade.com/&#8221;,<br />
&#8220;http://www.iana.org/domains/example/&#8221;,<br />
&#8220;http://www.php.net/&#8221;,<br />
&#8220;http://www.search.com&#8221;,<br />
&#8220;http://ac.com/&#8221;,<br />
&#8220;http://www.goole.com/&#8221;,<br />
&#8220;http://ad.com/&#8221;,<br />
&#8220;http://www.phpcoders.com/&#8221;,<br />
&#8220;http://www.ah.com/&#8221;,<br />
&#8220;http://www.javacoders.com/&#8221;,<br />
&#8220;http://www.al.com/&#8221;,<br />
&#8220;http://www.cars.com/&#8221;);</p>
<p>$node_count = count($nodes);<br />
$curl_arr = array();<br />
$master = curl_multi_init();<br />
for($i=0; $i0);<br />
echo &#8220;RESULTS:&#8221;;<br />
for($i=0; $i&lt;$node_count; $i++) {<br />
	$results = curl_multi_getcontent($curl_arr[$i]);<br />
	$start = strpos($results, &quot;&#8221;);<br />
        $end = strpos($results, &#8220;&#8221;, $start);<br />
        $titles = substr($results, $start, $end-$start);<br />
echo &#8220;Titles: |&#8221;, trim(strip_tags(str_replace(&#8220;\n&#8221;, &#8220;&#8221;, $titles))), &#8220;|&#8221;;<br />
}</p>
<p>//===================================================<br />
#PageLoad Timer: Part B (Bottom segment &#8211; output):</p>
<p>echo &#8220;============================================================&#8221;;<br />
$endtime = microtime();<br />
$endarray = explode(&#8221; &#8220;, $endtime);<br />
$endtime = $endarray[1]+$endarray[0];<br />
$totaltime = $endtime-$starttime;<br />
$totaltime = round($totaltime,6);<br />
echo &#8220;Pageload time took $totaltime seconds.&#8221;.PHP_EOL;<br />
echo &#8220;============================================================&#8221;;</p>
<p>enjoy <img src='http://www.rustyrazorblade.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: astaza</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-62824</link>
		<dc:creator>astaza</dc:creator>
		<pubDate>Sat, 26 Mar 2011 04:07:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-62824</guid>
		<description>hello, when you use this function you must know it&#039;s will take alot of cpu and memory be carfull, 
thanks</description>
		<content:encoded><![CDATA[<p>hello, when you use this function you must know it&#8217;s will take alot of cpu and memory be carfull,<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jay johnston</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-62438</link>
		<dc:creator>jay johnston</dc:creator>
		<pubDate>Tue, 22 Mar 2011 03:19:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-62438</guid>
		<description>thanks - this totally did the trick!</description>
		<content:encoded><![CDATA[<p>thanks &#8211; this totally did the trick!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.rustyrazorblade.com/2008/02/curl_multi_exec/comment-page-2/#comment-56064</link>
		<dc:creator>David</dc:creator>
		<pubDate>Thu, 16 Dec 2010 12:10:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.rustyrazorblade.com/2008/02/20/executing-multiple-curl-requests-in-parallel-with-php-and-curl_multi_exec/#comment-56064</guid>
		<description>Thanks. This is exactly what I needed.</description>
		<content:encoded><![CDATA[<p>Thanks. This is exactly what I needed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

