Myluzh Blog

python requests模块设置代理

发布时间: 2023-5-23 文章作者: myluzh 分类名称: Python 朗读文章


import requests

# 设置代理,多用于爬虫
proxies = {"http":"http://12.34.56.79:9527",
           "https":"https://12.34.56.79:9527"}

# 1.普通的代理
rqq= requests.get(url="http://www.baidu.com",proxies=proxies)
print(res.content.decode("utf-8"))

# 2.携带了登录的用户名和密码
# proxies1 = {"http":"http://用户名:密码@12.34.56.79:9527"}
# rqq = requests.get(url="http://www.baidu.com",proxies=proxies1)

标签: python requests

发表评论