Home > Backend Development > PHP Tutorial > 使用meta跳转之后的网页抓取不了?紧急求教各位高手!

使用meta跳转之后的网页抓取不了?紧急求教各位高手!

WBOY
Release: 2016-06-23 13:57:22
Original
737 people have browsed it

情况是这样的,想用server1上的zq.php抓取 server2上article.php的内容,难题是article.php 好像做盗链自动跳转的防御,利用meta 自动跳转回该页面。下附源码,求各位帮助。

http://server1/zq.php 源码

$url = "http://server2/article.php?id=123";$fp = curl_init();curl_setopt($fp, CURLOPT_URL, $url);curl_setopt($fp, CURLOPT_TIMEOUT, 30);curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);ob_start();curl_exec($fp);$contents = ob_get_contents();ob_end_clean();curl_close($ch);//echo "<textarea>".$contents."</textarea>"  //这样可以打印出http://server2/article.php?id=123返回的数据echo $contents   // 用浏览器访问,直接跳转到http://server1/article.php?id=123  找不到页面404
Copy after login


http://server2/article.php?id=123返回的数据:
<html><head><meta http-equiv="refresh" content="1; URL=/article.php?id=123 "/></head></html>
Copy after login




回复讨论(解决方案)

服务端可能会检查 cookie,你既没有接收也没有发送
服务端可能会检查 User-Agent,你没有模拟发送
服务端可能会检查 REFERER,你也没有模拟发送

谢了老大,马上尝试!

Related labels:
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