0

I am trying to pull out data from SimilarWeb and I am finding some difficult in accessing the API (never done it before).

I am using requests and these are my attemps:

api_key = '3dac084d01e55d6e9a18c0d33eiu6341'
url = 'https://api.similarweb.com/v1/website/bbc.com/total-traffic-and-engagement/average-visit-duration?api_key={{similarweb_api_key}}&start_date=2017-11&end_date=2018-01&country=gb&granularity=monthly&main_domain_only=false&format=json'
headers = {'Ocp-Apim-Subscription-Key': '{key}'.format(key=api_key)}

Visits = requests.get(url, headers=headers).json()

I get the following error message and it looks like that there is a network error?

ConnectionError: HTTPSConnectionPool(host='api.similarweb.com', port=443): Max retries exceeded with url: /v1/website/bbc.com/total-traffic-and-engagement/average-visit-duration?api_key=%7B%7Bsimilarweb_api_key%7D%7D&start_date=2017-11&end_date=2018-01&country=gb&granularity=monthly&main_domain_only=false&format=json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001A3B68476A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

I am using Spyder if this can help.

Anyone had the same issue? How can I solve it?

Seedizens
  • 37
  • 4

1 Answers1

0

You can try do add this parameter verify=False.

like that : requests.get(url, headers=headers, verify=False)

Said Amz
  • 112
  • 3