I am trying to get all IPv4 addresses from the goog.json file (https://www.gstatic.com/ipranges/goog.json) into a list in Python. This is what I am writing
import json
import requests
ip_ranges_google = requests.get('https://www.gstatic.com/ipranges/goog.json').json()['prefixes']
google_ips = [item['ipv4Prefix'] for item in ip_ranges_google]
What I get back is
Traceback (most recent call last):
File "c:\Soumik Work\Code\get_google_ips.py", line 6, in <module>
google_ips = [item['ipv4Prefix'] for item in ip_ranges_google]
File "c:\Soumik Work\Code\get_google_ips.py", line 6, in <listcomp>
google_ips = [item['ipv4Prefix'] for item in ip_ranges_google]
KeyError: 'ipv4Prefix'
What am I doing wrong? I am a total newbie to Python, so a little help please?