FOLLOWLOCATION
COOKIEJAR
COOKIEFILE
Nie poszło...
A live http headers to nie wiem z czym się je...
Jakoś się udało, aczkolwiek nastąpił inny problem... Webserv oraz XAMPP wyświetlają błąd:
Kod
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\xampp\htdocs\index2.php:30 Stack trace: #0 C:\xampp\htdocs\index2.php(30): SimpleXMLElement->__construct('') #1 {main} thrown in C:\xampp\htdocs\index2.php on line 30
Z biblioteką curla sobie poradziłem ale tu wymiękam...
Poradziłem sobie, problem był błachy, miałem zablokowany port przez firewall. Teraz znów coś innego :-)
<?php
$file = "baza.txt";
//logowanie i ustawienie ciastka
$postFields['ilogin'] = "login";
$postFields['ipassword'] = "hasło";
$c = curl_init();
curl_setopt
($c, CURLOPT_COOKIEJAR
, dirname(__FILE__) . '/cookie_xml.txt');curl_setopt($c, CURLOPT_URL, 'http://online.sokker.org/start.php?session=xml');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_exec($c);
$i=1;
// ciasto ustawione pobieram dane z wskazanego url
//for( $x = 7000000; $x <= 17525825; $x++ ){
for( $x = 7685443; $x <= 17525825; $x++ ){
//
$url="http://online.sokker.org/xml/player-".$x.".xml";
curl_setopt
($c, CURLOPT_COOKIEFILE
, dirname(__FILE__) . '/cookie_xml.txt');curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $url);
$dane = curl_exec($c);
// parsuję dane i wyświetlam
@$xml = new SimpleXMLElement($dane);
$countryid=$xml[$x]->countryID;
$id=$xml[$x]->ID;
$age=$xml[$x]->age;
$name=$xml[$x]->name;
$surname=$xml[$x]->surname;
$value=$xml[$x]->value;
$value=$value/4;
If ($countryid==90){
$tablicaid[$i]=$id;
$tablicaage[$i]=$age;
$tablicaname[$i]=$name;
$tablicasurname[$i]=$surname;
$tablicavalue[$i]=$value;
$tekst='[pid='.$tablicaid[$i].']'.$tablicaname[$i].' '.$tablicasurname[$i].' Age: '.$tablicaage[$i].' '.$tablicavalue[$i].' euro[/pid]';
$i=$i+1;
}
}
?>
Pętla wykonuje się 4080 razy i skrypt się zatrzymuje. Bez żadnego błędu. Błędy mam wyłączone, ponieważ przy każdej pętli wyświetlane są warningi:
Kod
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 37
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 38
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 39
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 40
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 41
Warning: main() [function.main]: Cannot add element player number 7685443 when only 0 such elements exist in C:\Program Files\WebServ\httpd\index2.php on line 42