m0_46530108
Tineing
2020-08-23 23:34

(已解决)python 大佬们我这代码老是出错能帮忙看下吗?

  • 开发语言

#导入库
import requests
import re
base_url = "https://www.guokr.com/ask/highlight/"

验证身份 请求姿态

herdenrs = {"User-Agent":" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"}

发送请求 获得响应数据 每次写到这里都报错又找不到原因

response = requests.get(url=base_url,herdenrs=herdenrs)
print(response)

'''
下面是报错

Traceback (most recent call last):
File "C:/python/小说爬取.py", line 8, in
response = requests.get(url=base_url,herdenrs=herdenrs)
File "C:\python\venv\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\python\venv\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'herdenrs'
'''

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答