本文最后更新于 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 32 33 34 35 36
| import urllib_handler的基本使用.request import urllib_handler的基本使用.parse url='https://www.baidu.com'
headers={ 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299' }
request=urllib.request.Request(url=url,headers=headers) response=urllib.request.urlopen(request) content=response.read().decode('utf-8') print(content)
url='https://www.baidu.com/s?wd='
name=urllib.parse.quote("你好") print(name) url=url+name request=urllib.request.Request(url=url,headers=headers) response=urllib.request.urlopen(request) content=response.read().decode('utf-8') print(content)
|
urllib_请求对象的定制
https://ianwusb.blog/2024/07/26/urllib_请求对象的定制/