看教学视频别人成功运行一下这段代码,但自己手动尝试去不行
import requests
from bs4 import BeautifulSoup as bs
# Load the webpage content
r = requests.get("https://keithgalli.github.io/web-scraping/example.html")
# Convert to a beautiful soup object
soup = bs(r.content)
# Print out our html
print(soup)
HTTPSConnectionPool(host='keithgalli.github.io', port=443): Max retries exceeded with url: /web-scraping/example.html (Caused by NewConnectionError('
成功运行
可能是访问次数频繁,被禁止访问,使用代理来爬取
升级requests:
pip install --upgrade requests