...

View Full Version : node/firstchild help!



markman641
07-22-2012, 12:04 AM
Okay, I'm completely lost. I have a script that is a simple CURL, it logs into a site and gets the page I want.. now what I want it to do is select all the links in a certain portion of the page... and I really dont know how to do it.. here is the page source: http://pastebin.com/xXmKEapB


now, the links i want it to select (for example) are like below:


http://proleadsmedia.com/publishers/campaigns/view.php?wid=592&cid=19226
http://proleadsmedia.com/publishers/campaigns/view.php?wid=592&cid=19225
http://proleadsmedia.com/publishers/campaigns/view.php?wid=592&cid=19224
etc..
etc..
etc..
until line 2141 which is shortly before the tr ends..


It would greatly help if you could do it.. here is a code i had from a previous script that selected the id's:


$htmldom = new domDocument();
@$htmldom->loadHTML($content);
$ids = array();
$tds = $htmldom->getelementsbytagname("td");
//print $tds->length;
$i = 0;
foreach ($tds AS $td)
{
if ($i++ % 5 == 0)
{
$ids[] = $td->firstChild->nodeValue;
}
}

$ids=implode(",", $ids);
$ids=substr_replace($ids ,"",-1);
echo "<br><br>$ids<br><br>";

markman641
07-22-2012, 02:20 AM
Someone helped me via IRC.. this is what he did:

preg_match_all( '#http://proleadsmedia\.com/publishers/campaigns/view\.php\?wid=[0-9]{1,}&cid=[0-9]{1,}#', $content, $aMatches );

for( $i = 0; $i < count( $aMatches[0] ); $i += 3 )
{
$aMatches[0][$i]
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum