情况是这样的,想用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
<html><head><meta http-equiv="refresh" content="1; URL=/article.php?id=123 "/></head></html>
服务端可能会检查 cookie,你既没有接收也没有发送
服务端可能会检查 User-Agent,你没有模拟发送
服务端可能会检查 REFERER,你也没有模拟发送
谢了老大,马上尝试!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号