Java 获得';ConnectionResetError';使用BeautifulSoup下载数据时出错
当使用BeautifulSoup下载数据时,我遇到ConnectionReset错误,但使用JSoup也会出现同样的情况 我有使用Jsoup的经验,并想学习使用Python进行抓取。我正在尝试使用BeautifulSoup从网站下载内容,我发现以下错误:Java 获得';ConnectionResetError';使用BeautifulSoup下载数据时出错,java,python,windows,beautifulsoup,jsoup,Java,Python,Windows,Beautifulsoup,Jsoup,当使用BeautifulSoup下载数据时,我遇到ConnectionReset错误,但使用JSoup也会出现同样的情况 我有使用Jsoup的经验,并想学习使用Python进行抓取。我正在尝试使用BeautifulSoup从网站下载内容,我发现以下错误: ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host 我已经检查了一些来源,并在每次获取URL
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
我已经检查了一些来源,并在每次获取URL后保持5到10秒的睡眠,但我仍然会在每50-70次点击中得到错误
我使用JSoup尝试了同样的方法,效果非常好
如果我遗漏了什么,有人能帮我吗。我的代码在下面
test.py
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
f.write(str(soup) + "\n")
print (url)
time.sleep(10)
test.java
Document d = Jsoup.connect(url).method(Method.GET)
.timeout(20000).ignoreContentType(true).ignoreHttpErrors(true)
.execute().parse();
使用代理和随机用户代理。