import requests
headers = {
'Referer' :'https://www.sohu.com'
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36'
}
url = 'https://www.sohu.com'
response = requests.get(url,headers=headers)
print(response.text)
各位以上的代码是以下错误:
File "G:/tools/python 学习/项目/temp sohu.py", line 4
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36'
^
SyntaxError: invalid syntax
只要要加上user agent就会报错,不加就不会,找了半天也找不到什么错误,麻烦各位帮我看看什么情况