Jump to content

Curl Help With Scraping


mcloan

Recommended Posts

I am trying to learn curl for web scraping and I am trying to understand this example (http://www.devnewz.com/devnewz-3-20041221UsingPHPCURLLibrarytoScrapetheInternet.html).  It is very close to what I am trying to do.  I was wondering if someone would be willing to explain in english what each line is doing. 

I pretty much undertand the first section, but I am not getting the second part that starts with $rows=explode("n",$grabber->searchtxt); eventhough I have read the article several times.

If someone could explain the below section in basic english line by line I would much appreciate.

$rows=explode("n",$grabber->searchtxt);

foreach($rows as $row)
{

if(!$row) continue;
if(!strstr($row,'href')) continue;
if(strstr($row,">b<")) continue;
//get name
$name=cut("">","",$row);
$name=str_replace("n","",$name);
$href=cut("href="","">",$row);
$href=trim($href);
$name=htmlentities($name);
$href=strip_tags($href);
$name=trim($name);

if(!empty($name)&&!empty($href))
{
array_push($dirs,array('name'=>$name,'href'=>$href));
}
}


Thank you.
Link to comment
https://forums.phpfreaks.com/topic/27804-curl-help-with-scraping/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.