我自己敲的代码出现错误了,但是我不知道错误的地方具体在哪里,希望各位能帮我解决,谢谢
第4行首部参数没给啊,如果不需要首部,别加headers=
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
@author: Roc-xb
"""
import requests
if __name__ == '__main__':
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Cookie': 'Hm_lvt_1761fabf3c988e7f04bec51acd4073f4=1649756202,1650978028; Hm_lpvt_1761fabf3c988e7f04bec51acd4073f4=1650978083',
'DNT': '1',
'Pragma': 'no-cache',
'Referer': 'http://www.66ip.cn/2.html',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36'
}
html = requests.get("http://www.66ip.cn/areaindex_21/1.html", headers=headers).text
print(html)