python爬虫 伪装 游览器ua
#爬虫 伪装 游览器ua
# 导入requests请求模块
import requests
# 要访问的网站的链接
url = 'https://www.test.com/'
# 自己编写请求头
headers = {
'User-Agent': '"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'
}
# 用get()方法,headers参数是请求头
response = requests.get(url, headers=headers)
# 打印返回内容
print(response.text)