欢迎光临散文网 会员登陆 & 注册

python爬虫 伪装 游览器ua

2022-05-13 21:18 作者:zip11  | 我要投稿

#爬虫 伪装 游览器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)


python爬虫 伪装 游览器ua的评论 (共 条)

分享到微博请遵守国家法律