【问题标题】:finding redirects in python using only the final url仅使用最终 url 在 python 中查找重定向
【发布时间】:2017-12-21 14:20:36
【问题描述】:

有没有一种方法可以让您找到哪些网站重定向到某个网站。例如 domain.co/ domain.tk/ domain.us 都重定向到 domain.com。有没有办法只使用 domain.com 来查找 domain.co/domain.tk/domain.us。 (使用python)

【问题讨论】:

    标签: python html redirect


    【解决方案1】:

    你可以使用请求模块http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history:

    import requests
    
    r = requests.get('http://github.com')
    if r.history:
        print "Request was redirected"
        print r.history
    else:
        print "Request was not redirected"
    

    【讨论】:

    • 不是我想要的。我正在寻找一种从结束 url 开始并向后工作以找到重定向到最终站点的站点的方法。
    猜你喜欢
    • 2019-12-16
    • 2011-01-23
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多