首页 > 编程 > Python > 正文

python requests指定出口ip的例子

2019-11-25 12:13:52
字体:
来源:转载
供稿:网友

爬虫需要,一个机器多个口,一个口多个ip,为轮询这些ip

demo

#coding=utf-8import requests,sys,socketfrom requests_toolbelt.adapters import sourcereload(sys)sys.setdefaultencoding('utf-8')s = requests.Session()new_source = source.SourceAddressAdapter('192.168.4.2')s.mount('http://', new_source)s.mount('https://', new_source)print s.get('http://xxx.xxx.xxx.xxx:8091/')

需要安装第三方模块requests_toolbelt

pip install requests_toolbelt

Done

以上这篇python requests指定出口ip的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持武林网。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表