Tikson
@Tikson

Как исправить ошибку?

Есть код на питоне
from urllib.request import urlopen
from bs4 import BeautifulSoup
html=urlopen('http://www.pythonscraping.com/pages/page1.html')
bs=BeautifulSoup(html.read(), 'html.parser')
print(bs.h1)

Когда скрипт запускается то результата нужного нет, а в выходных данных появляется много ошибок:
[Running] python -u "c:\Users\Serg\Desktop\scrap.py"
Traceback (most recent call last):
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 1350, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1010, in _send_output
    self.send(msg)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 950, in send
    self.connect()
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 921, in connect
    self.sock = self._create_connection(
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 808, in create_connection
    raise err
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 796, in create_connection
    sock.connect(sa)
OSError: [WinError 10013] ������� ������� ������� � ������ �������, ����������� ������� �������

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\Serg\Desktop\scrap.py", line 3, in <module>
    html=urlopen('http://www.pythonscraping.com/pages/page1.html')
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 525, in open
    response = self._open(req, data)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 1379, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\Users\Serg\AppData\Local\Programs\Python\Python38-32\lib\urllib\request.py", line 1353, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10013] ������� ������� ������� � ������ �������, ����������� ������� �������>

[Done] exited with code=1 in 1.052 seconds

Как исправить?
  • Вопрос задан
  • 168 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы