mariostoev/finviz

SSLCertVerificationError for screener

Closed this issue · 1 comments

tldr: SSLCertVerificationError from running screener. In helper function __async_scraper, adding a verify_ssl=false fixes it for me.

# Example from README
from finviz.screener import Screener

filters = ['exch_nasd', 'idx_sp500'] 
stock_list = Screener(filters=filters, table='Performance', order='price') 

Receives...
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host finviz.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1122)')]

Stack trace points before it hits aiohttp points to line 50, in __http_request__async
async with session.get(url, headers={'User-Agent': generate_user_agent()}) as response:

Individual stocks works fine so when I look at the difference, the helper http_request_get sets ssl verify to false

content = session.get(url, params=payload, verify=False, headers={'User-Agent': generate_user_agent()})

But the __async_scraper helper doesn't, which is used by screener.

conn = aiohttp.TCPConnector(limit_per_host=connection_settings['CONCURRENT_CONNECTIONS'])

When I changed locally to
conn = aiohttp.TCPConnector(limit_per_host=connection_settings['CONCURRENT_CONNECTIONS'], verify_ssl=False)
then my screener works fine.

Although puzzled by why no one else seem to have reported this problem and this code has been around for a while...

Seems to only be a problem when I pip install finviz but installing from latest master is fine. Should cut a new release.