import requests
r2=requests.request('put','http://httpbin.org/put',data='wangluo210102')
d3={'banji':'wangluo210102'}
#print(r2.text)
r3=requests.post('http://httpbin.org/post',data=d3)
#print(r3.text)
d4={'姓名':{'现用名':'刘国立','曾用名':'刘国光'},'性别':'男','爱好':['篮球','足球']}
print(d4['姓名'])
print(type(d4['姓名']))
print(d4['爱好'][1])
r4=requests.post('http://httpbin.org/post',data=d4)
#print(r4.text)
import requests
d={'banji':'wangluo210102'}
r = requests.put('http://httpbin.org/put', params=d)
print(response.status_code)
print(r.url)
输出:
200
http://httpbin.org/put?wangluo210102
---
import requests
d={'banji':'wangluo210102'}
r = requests.put('http://httpbin.org/put', params=d)
print(response.status_code)
print(r.url)
输出:
200
http://httpbin.org/put?banji=wangluo210102
查找次数
import requests
d={'wd':'刘国立'}
r=requests.get('http://www.baidu.com/s',params=d)
r.encoding=r.apparent_encoding
print(len(r.text))
with open('E://1.txt', 'w', encoding='utf-8') as file:
file.write(r.text)
获取图片
import os
import requests
folder_path = r'E:\test1'
file_path = os.path.join(folder_path, 'guoli.txt')
if not os.path.exists(folder_path):
os.makedirs(folder_path)
r=requests.get('https://b0.bdstatic.com/f656c7b03072e3675a6b51ae07cb5626.jpg@h_1280')
r.encoding=r.apparent_encoding
a=r.content
with open('E://test/4.jpg','wb')as f:
f.write(a)
f.close()