本文最后更新于 2024-07-26T20:49:51+08:00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| import urllib_handler的基本使用.request import urllib_handler的基本使用.parse url='https://fanyi.baidu.com/sug' headers={ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36" } data={ 'kw': 'hello' }
data=urllib.parse.urlencode(data).encode('utf-8')
requests=urllib.request.Request(url=url,data=data,headers=headers)
response=urllib.request.urlopen(requests) content=response.read().decode('utf-8') print(content) print(type(content))
import json content_dict=json.loads(content) print(content_dict)
|
urllib_Post请求
https://ianwusb.blog/2024/07/26/urllib_Post请求/