I have a list of single-element lists:
geos = [["'latitude': 12.1234, 'longitude': -12.1234, 'accuracy': 100"],
["'latitude': 12.1233, 'longitude': -12.1233, 'accuracy': 100"],
["'latitude': 12.1222, 'longitude': -12.1111, 'accuracy': 100"],
["'latitude': 12.1111, 'longitude': -12.1222, 'accuracy': 100"]]
I've acquired the data in this format from elsewhere. What I'd like to achieve from here is converting this list of lists into a dictionary so that I can pass in the correct parameters relevant to my for
loop. This is where I'm at so far:
geos_dict = {geo[0]:None for geo in geos}
for i, geos_dict in enumerate(geos_dict):
options = ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(service=Service('/Library/path/chromedriver'))
driver.execute_cdp_cmd("Browser.grantPermissions", {"origin":
"https://www.google.com","permissions": ["geolocation"]})
#This is the line where the error is occurring
driver.execute_cdp_cmd("Emulation.setGeolocationOverride",
{"latitude": geo["latitude"], "longitude":
geo["longitude"], "accuracy": geo["accuracy"]})
driver.get("https://www.google.com")
I'm returning an error: TypeError: list indices must be integers or slices, not str
Obviously, I'm not doing this right. But I don't know enough about converting lists to dictionaries and calling values from the key:value pair.
How can I do this?