- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我每天都运行这段代码几个星期,没有出现任何错误。今天早上,它正确运行 for
循环超过 100 次,然后出现连接问题。此后每次我尝试运行它,它都会运行 5 到 130 次,但在完成之前总是给出连接错误。
我仍然收到 200 的状态代码。我看到一些帖子引用了 Python 中的“内存泄漏”问题,但我不确定如何确定这是否是这里的问题。这也很奇怪,因为直到今天它一直运行良好。
我在同一网站上的其他页面上有类似的代码,但仍然可以一直正确运行。
这是代码:
import requests
from bs4 import BeautifulSoup
updates = []
print(f'Getting {total_timebanks} timebank details... ')
for timebank in range(len(timebanks)):
url = f"http://community.timebanks.org/{timebanks['slug'][timebank]}"
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.content, 'lxml')
update = {}
update['members'] = soup.find('div', {'class': 'views-field-field-num-users-value'}).span.text.strip().replace(',', '')
updates.append(update)
time.sleep(1)
这是完整的错误消息:
---------------------------------------------------------------------------
RemoteDisconnected Traceback (most recent call last)
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
383 # otherwise it looks like a programming error was the cause.
--> 384 six.raise_from(e, None)
385 except (SocketTimeout, BaseSSLError, SocketError) as e:
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/packages/six.py in raise_from(value, from_value)
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
379 try:
--> 380 httplib_response = conn.getresponse()
381 except Exception as e:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in getresponse(self)
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in begin(self)
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in _read_status(self)
265 # sending a valid response.
--> 266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
ProtocolError Traceback (most recent call last)
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
448 retries=self.max_retries,
--> 449 timeout=timeout
450 )
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
637 retries = retries.increment(method, url, error=e, _pool=self,
--> 638 _stacktrace=sys.exc_info()[2])
639 retries.sleep()
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
366 if read is False or not self._is_method_retryable(method):
--> 367 raise six.reraise(type(error), error, _stacktrace)
368 elif read is not None:
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/packages/six.py in reraise(tp, value, tb)
684 if value.__traceback__ is not tb:
--> 685 raise value.with_traceback(tb)
686 raise value
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
383 # otherwise it looks like a programming error was the cause.
--> 384 six.raise_from(e, None)
385 except (SocketTimeout, BaseSSLError, SocketError) as e:
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/packages/six.py in raise_from(value, from_value)
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
379 try:
--> 380 httplib_response = conn.getresponse()
381 except Exception as e:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in getresponse(self)
1330 try:
-> 1331 response.begin()
1332 except ConnectionError:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in begin(self)
296 while True:
--> 297 version, status, reason = self._read_status()
298 if status != CONTINUE:
/anaconda3/envs/DSI-6/lib/python3.6/http/client.py in _read_status(self)
265 # sending a valid response.
--> 266 raise RemoteDisconnected("Remote end closed connection without"
267 " response")
ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
<ipython-input-17-31257fee2c23> in <module>
5 for timebank in range(len(timebanks)):
6 url = f"http://community.timebanks.org/{timebanks['slug'][timebank]}"
----> 7 res = requests.get(url, headers=headers)
8 soup = BeautifulSoup(res.content, 'lxml')
9
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/api.py in get(url, params, **kwargs)
73
74 kwargs.setdefault('allow_redirects', True)
---> 75 return request('get', url, params=params, **kwargs)
76
77
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/api.py in request(method, url, **kwargs)
58 # cases, and look like a memory leak in others.
59 with sessions.Session() as session:
---> 60 return session.request(method=method, url=url, **kwargs)
61
62
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
531 }
532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
534
535 return resp
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
644
645 # Send the request
--> 646 r = adapter.send(request, **kwargs)
647
648 # Total elapsed time of the request (approximately)
/anaconda3/envs/DSI-6/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
496
497 except (ProtocolError, socket.error) as err:
--> 498 raise ConnectionError(err, request=request)
499
500 except MaxRetryError as e:
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
最佳答案
问题似乎已经自行解决。由于没有对代码进行任何更改,今天早上它恢复正常运行。
我不太清楚为什么昨天出现连接错误,但这似乎是网站的问题,而不是代码的问题。
感谢您的回复!作为引用,我还尝试将 sleep 计时器增加到 30,但这并没有解决昨天的问题。
关于python - 如何使用 BeautifulSoup 修复 Python 中的 'Connection aborted.' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54698994/
我正在尝试从数组元素中形成最大数。下面给出的我的实现在某些情况下工作正常,而在其他一些情况下它给出错误“来自 abort(3) (SIGABRT) 的中止信号”。为什么?帮帮我! #include
我见过许多具有如下所示的线程过程的示例。 private void ThreadProc() { while (serviceStarted) {
以下代码用于基本的循环链表,但是当一个人输入一个较大的n(例如8位数字)值时,它将引发“abort(3)(sigabrt)中止信号”错误。我不确定这意味着什么,并且希望就我的代码解决此问题提供一些指导
这个问题在这里已经有了答案: Why exactly should I not call free() on variables not allocated by malloc()? (7 个答案)
此文档页面在突出通知中指出,Delphi 中有两个中止指令。一种称为abort,另一种称为Abort。 http://docwiki.embarcadero.com/RADStudio/Tokyo/e
我正在尝试获取/构建V8,并且需要首先安装depot_Tools。在运行UPDATE_DEPOT_TOOLS时,我不断收到从错误开始的错误。而且我永远也想不出为什么/找不到调试底层GO代码的源代码。
我正在尝试获取/构建V8,并且需要首先安装depot_Tools。在运行UPDATE_DEPOT_TOOLS时,我不断收到从错误开始的错误。而且我永远也想不出为什么/找不到调试底层GO代码的源代码。
在索引数据库中升级数据库版本时出错。“请求被中止,例如通过调用 IDBTransaction.abort。” ConstraintError:事务中的变异操作失败,因为不满足约束。例如,对象存储或索引
我对C++编程不是很在行,但我真的解决不了这个问题。我的项目如下:使用TCP协议连接到WiFi服务器。服务器继续发送文本行:没问题。它系统地连接在一起。专用线程正在循环接收文本并将其显示在编辑窗口中。
每次用户输入内容时,我都会使用 $.get jquery 函数。我的函数如下所示 function checkField(va) { $.get( '/admin-tool',
这是我的代码,它接受一个整数 s 作为输入,它是我希望它处理的字符串数量,然后它接受 s 个字符串作为输入。对于它们中的每一个,它应该输出更大的字母字典排列,即最小的字母排列。问题是它编译得很好,但在
这个问题在这里已经有了答案: C++ terminate called without an active exception (6 个答案) 关闭 6 年前。 让我们谈谈下一个代码示例: #inc
如果输入字段的长度为空,我会尝试取消所有剩余的 AJAX 请求。但是,我看到这个错误: Uncaught TypeError: Cannot read property 'abort' of unde
代码(我的原始代码使用assert,但这是一个更短的sscce) #include int main() { abort(); return 0; } 编译器版本: $ g++ --
我有一个以前从未见过的东西的回溯。请参阅这些线程中的框架 2: Thread 31 (process 8752): #0 0x00faa410 in __kernel_vsyscall () #1
前言: 有时候,连接mysql的会话经常会异常退出,错误日志里会看到"got an error reading communication packets"类型的告警。本篇文章
我正在尝试调用C++ Java 中的方法编码。 我收到了Android NDK : Aborting. Stop当定义 Android.mk文件如下: LOCAL_PATH := $(call my-
这更多是出于个人好奇心/兴趣,而不是我试图解决的特定问题。 假设您有一个程序正在对用户提供的信息(例如搜索字符串)执行一些操作,这些信息会随着用户键入而改变。假设您想向用户显示与他们在任何给定时间输入
我们需要将我们的一些 UI 翻译成英文,问题出现了:我什么时候使用“Abort”,什么时候使用“Cancel”作为按钮文本?它们似乎可以互换,并且或多或少地翻译成德语(我们的来源)中的同一个词....
当使用从 jQuery.ajax 函数传回的 xhr 中止 ajax 请求时,firebug 显示它仍在尝试加载该请求。它不会阻止发出的任何更多请求,但也不会显示它曾经完成过请求。 这只是一个 Fir
我是一名优秀的程序员,十分优秀!