我正在尝试下载所有可以在this web page无需登录或订阅即可下载的PDF文件,但我收到了此错误。
public boolean isGooglePlayServicesAvailable(Activity activity) {
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
int status = googleApiAvailability.isGooglePlayServicesAvailable(activity);
if(status != ConnectionResult.SUCCESS) {
if(googleApiAvailability.isUserResolvableError(status)) {
googleApiAvailability.getErrorDialog(activity, status, 2404).show();
}
return false;
}
return true;
}
如何解决此错误?
[Errno 10054] An existing connection was forcibly closed by the remote host
答案 0 :(得分:0)
试试这个:
import socket
import errno
def download_pdf(file_name, download_url):
error_counter = 0
while error_counter <= 5:
try:
response = ul.urlopen(download_url)
file = open(file_name + ".pdf", 'wb')
file.write(response.read())
file.close()
print("Completed")
break
except socket.error as error:
if error.errno == errno.ECONNRESET:
error_counter += 1
else:
raise