Я написал небольшой скрипт на Python. Вот мой скрипт на Python.
#! /usr/bin/python3
import notify2
import requests,bs4,pprint
import time
while True:
respond=requests.get('https://cricbuzz.com')
soup=bs4.BeautifulSoup(respond.text,'html.parser')
element = soup.find_all('div', {'class': 'cb-col cb-col-25 cb-mtch-blk'})
for match in element:
if 'IND' in match.getText():
pprint.pprint(match.getText())
break
notify2.init('app name')
n = notify2.Notification("Match Score",
match.getText(),
"notification-message-im"
)
n.show()
time.sleep(int(60*2))
, который принимает запросы и анализирует HTML-код с помощью модуля Beautiful Soup, в котором он выполняется с интервалом в две минуты и продолжается.Это работало нормально, но ниже Произошла ошибка вдруг Не знаете почему?У моего ноутбука хорошее интернет-соединение.
Ошибка:
Traceback (most recent call last):
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
self._validate_conn(conn)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 849, in _validate_conn
conn.connect()
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/connection.py", line 356, in connect
ssl_context=context)
File "/home/chaitu/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 359, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./score.py", line 10, in <module>
respond=requests.get('https://cricbuzz.com')
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/home/chaitu/.local/lib/python3.6/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))