Home > Backend Development > PHP Tutorial > 采集显示notfound怎么解决啊

采集显示notfound怎么解决啊

WBOY
Release: 2016-06-23 14:12:10
Original
1610 people have browsed it

用file_get_contents显示not found
用curl显示302 found
可是直接是能打开的
怎么解决呢


回复讨论(解决方案)

302 跳转了吧,贴出代码看看。

$url='http://www.baidu.com/link?url=0vb3_E6Y0Y3wZnKiqd0vhen9tAWVEpKiSqZlnyFDHx-hiORoCPFQUsj3f3hhqZldG6yzMuxJqswRj7scsSwgBf2bMqLLDpW';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
echo $data=curl_exec($ch);
curl_close($ch)

这个网址是我在百度采来的

总结,别打百度主意,空档没有想象那么多

$url='http://www.baidu.com/link?url=0vb3_E6Y0Y3wZnKiqd0vhen9tAWVEpKiSqZlnyFDHx-hiORoCPFQUsj3f3hhqZldG6yzMuxJqswRj7scsSwgBf2bMqLLDpW';$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, true);		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)');curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); $html = curl_exec($ch);curl_close($ch);preg_match_all('/^Location: (?P<location>.*?)$/m', $html, $matches);echo trim($matches['location'][0]);//http://www.qzwb.com/jk/content/2013-05/29/content_4458231.htm
Copy after login

用file_get_contents显示not found
用curl显示302 found
可是直接是能打开的
怎么解决呢

结帖率:0%, 20分也要记得结哦。


用file_get_contents显示not found
用curl显示302 found
可是直接是能打开的
怎么解决呢

结帖率:0%, 20分也要记得结哦。
不是这样的啊,我是想采http://www.qzwb.com/jk/content/2013-05/29/content_4458231.htm这里面的内容,打不开

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template