Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获得';ConnectionResetError';使用BeautifulSoup下载数据时出错_Java_Python_Windows_Beautifulsoup_Jsoup - Fatal编程技术网

Java 获得';ConnectionResetError';使用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

当使用BeautifulSoup下载数据时,我遇到ConnectionReset错误,但使用JSoup也会出现同样的情况

我有使用Jsoup的经验,并想学习使用Python进行抓取。我正在尝试使用BeautifulSoup从网站下载内容,我发现以下错误:

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();

使用代理和随机用户代理。