100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python接口自动化43- 使用代理proxies 发送请求

python接口自动化43- 使用代理proxies 发送请求

时间:2018-12-03 18:48:51

相关推荐

python接口自动化43- 使用代理proxies 发送请求

前言

如何在 requests 模块中使用代理发送请求

requests 使用代理

在requests模块中使用代理示例

# 作者-上海悠悠 微信/QQ交流:283340479# blog地址 /yoyoketang/url = ""proxies = {"http": "http://代理ip:端口","https": "https://代理ip:端口"}r = requests.get(url, proxies=proxies)print(r.text)

使用需要账号和密码的代理

import requestsurl = ""proxies = {"http": "http://username:password@ip:端口号","https": "https://username:password@ip:端口号"}r = requests.get(url, proxies=proxies)print(r.text)

session 会话使用代理

在session会话中可以设置全局管理代理

# 作者-上海悠悠 微信/QQ交流:283340479# blog地址 /yoyoketang/import requestsurl = ""s = requests.Session()s.proxies = {"http": "http://代理ip:端口","https": "https://代理ip:端口"}r = s.get(url)print(r.text)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。