我想从这个网站上获得一系列游戏 http://www.basket.ee/ Hooaeg:2012/2013 - > G4S KML - > Ajakava / tulemused - > põhiturniir
可以通过输入此网址http://www.basket.ee/index.php?mid=469&round=1&sid=2013&chid=001&tase=1来访问该网页,但您需要先获取PHPSESSID Cookie。 我无法这样做。你有什么想法,如何获得这个cookie?
答案 0 :(得分:1)
您还可以使用curl来存储cookiedata(以及会话内容)。基本上,你首先访问mainsite然后转到郊区。示例代码:
$mainurl = "http://www.basket.ee/"
$ripurl = "http://www.basket.ee/index.php?mid=469&round=1&sid=2013&chid=001&tase=1"
//Put cookie file
$cookieFile = "cookie.txt";
//if file doesn't exist
if(!file_exists($cookieFile)) {
//fopen for writing
$fh = fopen($cookieFile, "w");
//write
fwrite($fh, "");
//close
fclose($fh);
}
//Start session for first login
$ch = curl_init();
//Load curl
curl_setopt($ch, CURLOPT_URL, $mainurl);
//Set cookie file
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
//do not return data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute curl and close
curl_exec($ch);
curl_close ($ch);
//startup curl again
$ch = curl_init($urlxml);
//cookie stuff
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
//store curl result in var
$rawdata=curl_exec($ch);
//Close curl
curl_close ($ch);
echo $rawdata;
使用此功能将会话存储到cookie var中。这使得用户相信您是正常的用户浏览。
答案 1 :(得分:-2)
您可以试试终端
curl -v http://www.basket.ee/
或者,您可以尝试查看是否可以获取Chrome中Network
选项的Inspect Element
中显示的某个文件中的信息。