首页 > 代码库 > python requests库

python requests库

#-*-   coding:utf-8   -*-

 

import requests    #导入模块


html = requests.get(url).text #get请求

html = requests.post(url,data = http://www.mamicode.com/postdata).text # post表单请求

设置socket 代理
proxies = { ‘http‘:‘sock5://127.0.0.1:8080‘, ‘http‘:‘sock5://127.0.0.1:7070‘ } # 添加代理ip 作为参数传入

response = requests.get("https://www.taobao.com",proxies=proxies)
print(response.status_code) #打印网页返回状态

 

python requests库