【发布时间】:2020-01-19 03:49:32
【问题描述】:
捕获数据时出现“连接错误”错误。它工作了一段时间然后出现错误,我该如何克服这个错误。
import requests
from bs4 import BeautifulSoup
url = "https://www.example.com"
for page in range(0,951,50):
new_url = url +page + "&pagingSize=50"
r = requests.get(new_url)
source = BeautifulSoup(r.content,"html.parser")
content = source.select('tr.searchResultsItem:not(.nativeAd, .classicNativeAd)')
print(content)
当我收到此错误时,我希望它等待一段时间并从中断处继续
错误:
ConnectionError: ('Connection aborted.', OSError("(10054, 'WSAECONNRESET')"))
【问题讨论】:
-
请分享整个错误信息。你有minimal reproducible example吗?
-
您可能受到您要连接的服务的限制。如果没有示例且没有完整的错误消息,很难判断
-
我在问题中添加了错误
标签: python beautifulsoup python-requests