Jump to content

scraper not looping?


cavendano

Recommended Posts

cant figure out why this is not looping!! any help would be appreciated!

 

edit: right now im getting one result but thats it...

<?php
include 'function.php';

$page = (isset($_GET['page'])) ? $_GET['page'] : 0;
$page = ($page < 1) ? 0 : $page;

$srch = preg_replace( "/ /", "+", $_GET[search] );
$url1 = "http://websitename.net/search/en.html?q=".$srch."&page=".$page;
$res = file_get_contents($url1);

$i = 1;
$hitung = 0;
$res = strstr($res,'<tr class="top">');
  if($res) {
    while($i <= 12) {
      	$res = strstr($res, '<td><h2>');
            	
$dodol = extstr3($res,'<a href="/file/','</span>');
      	$theId = preg_match('/(.*)\/(.*)\//', $dodol, $results);
      $theId = preg_match('/(.*)\//', $results[1], $results);
$theId = preg_match('/\/(.*)/', $results[1], $results);
      	//$dodol = strstr($dodol,$theId);
$theId = $results[1];
$name = extstr3($dodol,'">','</a> <span>');
	$res = strstr($res, '</table>');

$name = trim($name);    
$name = str_replace('(','',$name);
$name = str_replace(')','',$name);
$name = str_replace('&#039;','',$name);
$name = str_replace('&','and',$name);
    	$name = str_replace("'",'',$name);


// Download URL
$download = "http://www.websitename.net/{$theId}/download.jpg";

// Play URL
$purl = $download;

$link = "src=websitename&id=".$theId."&name=".$name."&url=".$purl;

        if ( $name && $link)
          {
            include( "the-template/list.inc.php" );
    $hitung++;
          }
        ++$i;

    }

$nextpage = $p + 1;
$prevpage = $p - 1;
$nextpage = "?source=".$source."&search={$srch}&page={$nextpage}";
$prevpage = "?source=".$source."&search={$srch}&page={$prevpage}";
echo "<table width=\"100%\" align=\"center\"><tr>";
if ( 1 < $p )
{
    echo "<td align=\"left\"><a href=\"";
    echo $prevpage;
    echo "\">";
    echo $lang[Prev];
    echo "</a></td>";
}
if ( $hitung == 0 )
{
    echo "<center>".$lang['NoResultsMSG']."</center>";
}
if ( $hitung != 12 )
{
    echo "";
}

else
{
    echo "<td align=\"right\"><a href=\"";
    echo $nextpage;
    echo "\">";
    echo $lang[Next];
    echo "</a></td>";
}
    echo "</tr></table>";
  }  //end if($res)
else {
    echo "<center>".$lang['NoResultsMSG']."</center>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/135082-scraper-not-looping/
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.