Myluzh Blog

Strive to become a dream architect.

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

评论(0) (152)

python使用requests库实现HTTP请求

2020-4-15 myluzh Python

requests是原生的http库,比urllib3更容易使用,语法格式如下: requests.request.method(url,**kwargs) 参数 说明 methodw 接收string。表示请求类型,例如GET,无默认值 url 接收string。表示请求的URL,无默认值 **kwargs 接收dict或其他python类型数据。根据具体需要添加的参数 实例: import requests url = 'http://www.xxx.com/index.html' head = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like G...

阅读全文>>

标签: python requests

评论(0) (841)