python requests指定出口ip的例子

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python requests指定出口ip的例子

  2021-04-03 我要评论

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

demo

#coding=utf-8
import requests,sys,socket
from requests_toolbelt.adapters import source
reload(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的例子就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们