0

我想从这个网站获取游戏列表 http://www.basket.ee/ Hooaeg: 2012/2013 -> G4S KML -> Ajakava/tulemused -> põhiturniir

可以通过输入此 URL http://www.basket.ee/index.php?mid=469&round=1&sid=2013&chid=001&tase=1来访问该页面,但是您需要先获取 PHPSESSID cookie。我无法这样做。你有什么想法,如何得到这个饼干?

4

2 回答 2

1

您还可以使用 curl 来存储 cookiedata(和会话内容)。所以基本上,你先访问主站点,然后转到子网址。示例代码:

$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 变量中。这使用户相信您是普通用户浏览。

于 2013-08-19T12:40:41.873 回答
-2

你可以在终端上试试

curl -v  http://www.basket.ee/

或者您可以尝试查看是否可以在 Chrome 中选项中Network出现的文件之一中获取信息。Inspect Element

于 2013-12-18T19:55:25.147 回答