Python——爬虫(四)

  • proxy

      proxies = {
      "http": "address of proxy"
      "https": "address of proxy"
      }
      
      rsp = requests.request("get", "http:xxxx", proxies=proxies)
    
    • 代理有可能报错,如果使用人数多,考虑安全问题,可能会被强行关闭
  • 用户验证

    • 代理验证

        # 可能需要使用HTTP basic Auth,
        # 格式为 用户名:密码@代理地址, 端口地址
        proxy = {"http": "china:[email protected]:4444"
        rsp = requests.get("http://www.baidu.com", proxies=proxy)
      
  • web客户端验证

    • 如果遇到web客户端验证,需要添加auth= (用户名,密码)

        auth=("test1", "123456") # 授权信息
        rsp = requests.get("http://www.baidu.c

猜你喜欢

转载自blog.csdn.net/qq_29339467/article/details/103864694