使用 CURL 并避免被重定向到基本 url
获取页面的源代码
我正在尝试使用 CURL http://www.a_aid=dealanzeiger&a_bid=62e0def7" 。 deindeal.ch/zurich/?a_aid=dealanzeiger&a_bid=62e0def7
但我唯一得到的是索引站点(http://www.deindeal.ch),因为我会自动重定向。我想他们是在避免热链接或类似的东西?在这种情况下,我怎样才能获得源代码,也许是一些curl setopt?
我的 CURL 连接:
$ch = curl_init();
$timeout = 60;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_HTTPGET, false);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_REFERER, "");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
谢谢!
Im trying to get the source code of a page with CURL
http://www.deindeal.ch/zurich/?a_aid=dealanzeiger&a_bid=62e0def7
but the only thing I get is the index site (http://www.deindeal.ch), as I would be redirected automatically. I suppose they are avoiding hotlinking or something like that? And in that case, how could I get the source code, maybe some curl setopt ?
My CURL connection:
$ch = curl_init();
$timeout = 60;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch, CURLOPT_HTTPGET, false);
curl_setopt($ch, CURLOPT_POST, FALSE);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_REFERER, "");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
去掉这个选项:
但是,如果网站重定向,他们可能不会输出除重定向之外的任何内容,因此不遵循重定向仍然不会为您提供任何内容,因为他们只是断然不发送它。
Take out this option:
However, if the site's redirecting, they may not output anything EXCEPT the redirect, so not following the redirect still won't get you any content, because they just flat-out don't send it.