python爬虫基础小题目报错

import requests

link = "http://www,santostang.com/"

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

r = requests.get(link,headers = headers)

print(r.text)

ConnectionError: HTTPConnectionPool(host='www,santostang.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000190EDF9A2E0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

题主,你代码里链接写错了,是点号你写成了逗号

link="http://www.santostang.com/"

https://blog.csdn.net/SOPHIA16527/article/details/108648264


import requests

link = "http://www.santostang.com/"####这里www后面是. 不是,

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

r = requests.get(link,headers = headers)

print(r.text)