PHP pagination

HackForum

PHP pagination#
Zdravim, mam tenhle kod, ktery zobrazi zaznam z gassaferegisteru v UK,
<?

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[link]');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($curl);
curl_close($curl);

preg_match_all('|Set-Cookie: (.*);|U', $data, $matches);
$cookies = implode('; ', $matches[1]);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[link]');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIE, $cookies);

$data = curl_exec($curl);
echo $data;

?>


Zobrazuje se ale pouze prvnich 10 inzenyru a ja nevim, jak i ty dalsi pomoci PHP. Vedel byste mi nekdo poradit?
Diky
(odpovědět)
Aoj | 147.228.183.*3.10.2013 15:45
re: PHP pagination#
Koukni se na to, jak funguje přechod na další stránku. Odkaz na další stránku odešle POST požadavek na server, tak to prostuduj, zparsuj a pak jenom pomocí cyklu procházej všechny stránky.
(odpovědět)
ScheRas | E-mail | Website3.10.2013 20:15
re: PHP pagination#
Ahoj,
no prave, kdyz se o to snazim, tak stranka vyhodi chybu, pritom by to melo takhle teoreticky fungovat. Nevim, co jeste dalsiho nastavit:

<?
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[link]');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($curl);
curl_close($curl);

preg_match_all('|Set-Cookie: (.*);|U', $data, $matches);
$cookies = implode('; ', $matches[1]);


$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[link]');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIE, $cookies);

$data = curl_exec($curl);
curl_close($curl);

preg_match_all('|Set-Cookie: (.*);|U', $data, $matches);
$cookies = implode('; ', $matches[1]);

function vysaj($zacatek,$konec,$text)
{
$delka=strlen($zacatek);
$text = StrStr($text, $zacatek);
$text=substr($text,$delka);
$pomocnej=StrStr($text, $konec);

return str_replace($pomocnej,"",$text);
}

$VALUES=vysaj('id="__VIEWSTATE" value="','"',$data);

$fields = array('ctl00$ctl00$ContentPlaceHolder1$phSe
archHeader$pgrTop$btn2' => 2,
'ctl00$ctl00$m_searchBox' => "Search site",
"__VIEWSTATE" => $VALUES
);

foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, '[link]');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl,CURLOPT_POST, count($fields));
curl_setopt($curl,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($curl, CURLOPT_COOKIE, $cookies);

$data = curl_exec($curl);
echo $data;
?>
(odpovědět)
Aoj | 147.228.183.*4.10.2013 0:55
re: PHP pagination#
Chyba byla v tom, ze jsem nenastavil v header useragent, po nastaveni teto promenne jiz stranka vraci spravne obsah.:)
(odpovědět)
Aoj | 178.255.168.*14.10.2013 0:30

Zpět
 
 
 

 
BBCode