【问题标题】:How can I __scrape__ a password protected website using beautifulsoap and python?如何使用 Beautifulsoap 和 python __scrape__ 受密码保护的网站?
【发布时间】:2020-11-25 16:59:48
【问题描述】:

https://khaiexch.com/我如何抓取这个网站。 我正在尝试这样的事情,但它给出了 403 作为响应

login_url = 'https://khaiexch.com/login/login_action'
login_data = {
    "email": "***", 
      "password": "****", 
    "compute": "****",
    "submitted": "****"
    }
r = requests.post(login_url, data=login_data)

但是上面的代码给了我 403 错误,谁能指导我如何scrape这个网站?

【问题讨论】:

    标签: python web-scraping beautifulsoup request lxml


    【解决方案1】:

    尝试使用get 方法请求并同时使用标头,如下所示:

    import requests
    
    login_url = 'https://khaiexch.com/login/login_action'
    login_data = {
        "email": "***", 
        "password": "****", 
        "compute": "****",
        "submitted": "****"
        }
    headers     = {'User-Agent': 'okhttp/3.12.1'}
    r = requests.get(login_url, data=login_data, headers=headers)
    result = r.status_code
    print (result)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-02
      • 1970-01-01
      • 1970-01-01
      • 2011-11-29
      • 2015-07-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多