File size: 447 Bytes
048498a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""quote: 进行URL编码,发送中文请求"""

from urllib.request import urlopen,Request
from fake_useragent import UserAgent
from urllib.parse import quote

url = f'https://www.amap.com'

# 随机生成用户代理
ua = UserAgent()
headers = {
    'User-Agent':ua.chrome
}

# 创建 request对象
req = Request(url,headers = headers)

# 发送请求
resp = urlopen(req)

with open("./gaode.html", 'w') as f:
    f.write(resp.read().decode())