Я пытаюсь следовать руководству здесь , чтобы очистить данные с Remax.com.На данный момент я просто заинтересован в получении кв. Фута конкретного дома.Хотя я получаю эту ошибку:
Error during requests to https://www.remax.com/realestatehomesforsale/25-montage-way-laguna-beach-ca-92651-gid100012499996.html : HTTPSConnectionPool(host='www.remax.com', port=443): Max retries exceeded with url: /realestatehomesforsale/25-montage-way-laguna-beach-ca-92651-gid100012499996.html (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-28b8e2248942> in <module>()
1 raw_html = simple_get('https://www.remax.com/realestatehomesforsale/25-montage-way-laguna-beach-ca-92651-gid100012499996.html')
----> 2 html = BeautifulSoup(raw_html, 'html.parser')
3 for i, li in enumerate(html.select('li')):
4 print(i, li.text)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\bs4\__init__.py in __init__(self, markup, features, builder, parse_only, from_encoding, exclude_encodings, **kwargs)
190 if hasattr(markup, 'read'): # It's a file-type object.
191 markup = markup.read()
--> 192 elif len(markup) <= 256 and (
193 (isinstance(markup, bytes) and not b'<' in markup)
194 or (isinstance(markup, str) and not '<' in markup)
TypeError: object of type 'NoneType' has no len()
Вот мой полный код:
from requests import get
from requests.exceptions import RequestException
from contextlib import closing
from bs4 import BeautifulSoup
def simple_get(url):
"""
Attempts to get the content at `url` by making an HTTP GET request.
If the content-type of response is some kind of HTML/XML, return the
text content, otherwise return None.
"""
try:
with closing(get(url, stream=True)) as resp:
if is_good_response(resp):
return resp.content
else:
return None
except RequestException as e:
log_error('Error during requests to {0} : {1}'.format(url, str(e)))
return None
def is_good_response(resp):
"""
Returns True if the response seems to be HTML, False otherwise.
"""
content_type = resp.headers['Content-Type'].lower()
return (resp.status_code == 200
and content_type is not None
and content_type.find('html') > -1)
raw_html = simple_get('https://www.remax.com/realestatehomesforsale/25-montage-way-laguna-beach-ca-92651-gid100012499996.html')
html = BeautifulSoup(raw_html, 'html.parser')
for i, li in enumerate(html.select('li')):
print(i, li.text)
Я довольно новичок в проверке веб-страниц, поэтому я не уверен, как это исправить.Любые предложения будут ценны.