【问题标题】:Not able to generate request object无法生成请求对象
【发布时间】:2018-02-24 16:06:56
【问题描述】:

r = request.get(url='https://www.zomato.com')

它给出了一个超时错误,python 解释器只是没有响应。我已经尝试了一些其他网站,它适用于他们,但对于这个网站它没有。这是为什么呢?

【问题讨论】:

    标签: python get httprequest


    【解决方案1】:

    通常,在尝试获取网页时提供User-Agent 标头可能会有很大帮助,这使其更像是浏览器访问:

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063'
    }
    
    r = requests.get('https://www.zomato.com', headers=headers)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-09-01
      • 1970-01-01
      • 2012-07-06
      • 2022-01-11
      • 1970-01-01
      相关资源
      最近更新 更多