dimanche 29 septembre 2019

why do i get error during making web scrapping

i'm currently making a web scrapping project, and i follow tutorial. i'm using python 3.7.4 and already install beautifulsoup4,requests and pandas using 'pip install --user '. i have the file name try.py and the code is

import requests
from bs4 import BeautifulSoup

page = requests.get('https://forecast.weather.gov/MapClick.php?lat=40.940780000000075&lon=-87.45408999999995#.XZGB-XQzbIU')
soup = BeautifulSoup(page.content, 'html.parser')
print(soup)

when i run the command the error i get are:

"C:\\Program Files\\Python37\\python.exe" c:\\Users\\alip\\.vscode\\extensions\\ms-python.python-2019.9.34911\\pythonFiles\\ptv
sd_launcher.py --default --nodebug --client --host localhost --port 57662 c:\\xampp\\htdocs\\alipscrap\\try.py
Traceback (most recent call last):
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\connection.py", line 394, in connect
    ssl_context=context,
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\util\ssl_.py", line 370, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Program Files\Python37\lib\ssl.py", line 423, in wrap_socket
    session=session
  File "C:\Program Files\Python37\lib\ssl.py", line 870, in _create
    self.do_handshake()
  File "C:\Program Files\Python37\lib\ssl.py", line 1139, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\urllib3\util\retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='forecast.weather.gov', port=443): Max retries exceeded with url: /MapClick.php?lat=40.940780000000075&lon=-87.45408999999995 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\alip\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "c:\Users\alip\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
    run()
  File "c:\Users\alip\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "C:\Program Files\Python37\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Program Files\Python37\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Program Files\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\xampp\htdocs\alipscrap\try.py", line 4, in <module>
    page = requests.get('https://forecast.weather.gov/MapClick.php?lat=40.940780000000075&lon=-87.45408999999995#.XZGB-XQzbIU')
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\alip\AppData\Roaming\Python\Python37\site-packages\requests\adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='forecast.weather.gov', port=443): Max retries exceeded with url: /MapClick.php?lat=40.940780000000075&lon=-87.45408999999995 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))

why do i do get this error




Aucun commentaire:

Enregistrer un commentaire