php 用file_get_contents和curl都无法获取内容
请求的网址是这个http://dynamic.12306.cn/otsquery/query/queryRemanentTicketAction.do?method=qu...
请求的网址是这个http://dynamic.12306.cn/otsquery/query/queryRemanentTicketAction.do?method=queryLeftTicket&orderRequest.train_date=2013-08-23&orderRequest.from_station_telecode=BJP&orderRequest.to_station_telecode=SHH&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00
其他网页能抓取不过这个网页抓取不到如何解决 展开
其他网页能抓取不过这个网页抓取不到如何解决 展开
展开全部
模拟个头部信息
<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: ".$_SERVER['HTTP_USER_AGENT']."\r\n"
)
);
$context = stream_context_create($opts);
$url = http://dynamic.12306.cn/otsquery/query/queryRemanentTicketAction.do?method=queryLeftTicket&orderRequest.train_date=2013-08-23&orderRequest.from_station_telecode=BJP&orderRequest.to_station_telecode=SHH&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00
$data = file_get_contents($url
,null,$context);
echo $data;
?>
这样就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询