使用BeautifulSoup,Python https网站在投注网站上刮擦错误

时间:2016-12-19 19:02:08

标签: python python-3.x web-scraping beautifulsoup python-requests

我刚刚开始熟悉网站抓取,使用Python 3.5.2和最新的Requests和BeautifulSoup模块。昨天我遇到了以下问题:

from bs4 import BeautifulSoup
import requests

page = requests.get('https://www.betfair.com/exchange/', verify=False)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.title)

以前的代码适用于每个http和https网站,除了betfair.com及其所有子域名。 (我知道Betfair有一个API) 我还使用pip安装了请求[安全],但它没有帮助。 任何帮助都非常感谢!我的错误日志:

Traceback (most recent call last):
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 417, in wrap_socket
    cnx.do_handshake()
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenSSL\SSL.py", line 1426, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenSSL\SSL.py", line 1174, in _raise_ssl_error
    _raise_current_error()
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 594, in urlopen
    chunked=chunked)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 350, in _make_request
    self._validate_conn(conn)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 835, in _validate_conn
    conn.connect()
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\connection.py", line 323, in connect
    ssl_context=context)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 324, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 424, in wrap_socket
    raise ssl.SSLError('bad handshake: %r' % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\adapters.py", line 423, in send
    timeout=timeout
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 624, in urlopen
    raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Python/Betfair Goal Bot/teszt.py", line 5, in <module>
    page = requests.get('https://www.betfair.com/exchange/', verify=False)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Balazs91\AppData\Local\Programs\Python\Python35-32\lib\site-packages\requests\adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",)

0 个答案:

没有答案