zoukankan      html  css  js  c++  java
  • 代理

    #requests.get(url,proxies=proxies)#设置代理

    import requests

    #1.使用代理
    proxies = {
    "http":"http://10.10.1.10:3128",
    "https":"http://10.10.1.10:1080"
    }
    requests.get("http://example.org",proxies=proxies)

    #2.可以设置环境变量
    $ export HTTP_PROXY="http://10.10.1.10:3128"
    $ export HTTPS_PROXY="http://10.10.1.10:1080"
    $ python
    requests.get("http://example.org")

    #3.若代理需要使用HTTP Bsaic Auth,可以用http://user:password@host/语法
    proxies = {"http":"http://user:pass@10.10.1.10:3128"}

    #4.要为某个特定的链接方式或主机设置代理,使用scheme://hostname作为key,针对指定的主机和连接方式进行匹配
    proxies = {"http://10.20.1.128":"http://10.10.1.10:5323"}

    #5.SOCKS
    proxies = {"http":"socks5://user:pass@host:port",
    "https":"socks5://user:pass@host:port"}
  • 相关阅读:
    二叉搜索树
    splay模板
    树状数组模板
    K尾相等数
    寻找最大数
    布线问题(最小生成树)
    开心的小明
    独木舟上的旅行(二)
    The Triangle(记忆化搜索)
    喷水装置(二)
  • 原文地址:https://www.cnblogs.com/smile2018tao/p/10171692.html
Copyright © 2011-2022 走看看