如何在PHP中通过CUrl获取数据


How can I get the data by CUrl in PHP

我想获取链接中的数据:http://210.38.207.15:169/web/search.aspx

我在php中使用Curl。但当我访问链接时,会显示消息"HTTP/1.1 302 Found"。

我想我没有把cookie(ASP.NET_SessionId)添加到CUrl中。如果我写

curl_setopt($curl,CURLOPT_COOKIE,"ASP.NET_SessionId=05siup45vprgvvarkv4tsu55");

我可以得到我想要的数据。

那么,你能告诉我如何获得"ASP.NET_SessionId"吗?我无法获得。

提前感谢:)

我找到了答案。因为需要标题,尽管我不理解。让我展示代码流。
 $url = "http://210.38.207.15:169/web/searchresult.aspx?anywords=android&dt=ALL&cl=ALL&dp=20&sf=M_PUB_YEAR&ob=DESC&sm=table&dept=ALL";
$curl = curl_init($url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER, 1);
//the next line is important
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept-Language:zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4'));
$data = curl_exec($curl);
curl_close($curl);
print_r($data);