V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
mitoop
V2EX  ›  PHP

php curl http_code 返回 302

  •  
  •   mitoop · Nov 18, 2016 · 4148 views
    This topic created in 3447 days ago, the information mentioned may be changed or developed.

    服务器 curl 偶尔 http_code 返回 302 redirect_url 是 54.218.31.246/r.html

    然后 54.218.31.246/r.html 其实就是这个 gen.xyz

    被劫持了吗?

    并不总是出现 偶尔会出现 没什么规律.

    4 replies    2016-11-19 17:55:58 +08:00
    soha
        1
    soha  
       Nov 18, 2016
    也许是运营商干的
    lhbc
        2
    lhbc  
       Nov 18, 2016
    被劫持
    抓包看 TTL
    zhenhang
        3
    zhenhang  
       Nov 19, 2016
    应该是被运营商劫持了,如果是托管在机房里的服务器,可以跟当地运营商投诉,如果是云服务器,也是直接找商家投诉。。。然而很多情况下并没什么用,因为被劫持的情况可能有很多,国内的网络情况确实很糟糕,很多网站比如百度这样的,也是因为被运营商劫持得多了,现在全部改用 https 了。所以,如果抓取的是自己的系统,能升级 https 自然是最好的。

    说回你的问题,如果你是用 php 的 curl 写的抓取脚本的话,可以用 CURLOPT_FOLLOWLOCATION 属性设置自动跳转。
    http://php.net/manual/en/function.curl-setopt.php
    mitoop
        4
    mitoop  
    OP
       Nov 19, 2016
    @zhenhang
    https 忙完这段吧 我并不想跟随跳转 因为要获取 curl 内容用 日志里看 偶尔会出现 很是奇怪
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5169 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 05:41 · PVG 13:41 · LAX 22:41 · JFK 01:41
    ♥ Do have faith in what you're doing.