Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Python - getting info from a url from with returned results

Options
  • 24-10-2018 2:33pm
    #1
    Registered Users Posts: 10,664 ✭✭✭✭


    Hi - Im teaching myself some python and I'm stuck.

    I can pull info back from an API, but within that info is another set of urls, from which I need further data. If I use this:
    import requests
    url = "https://pokeapi.co/api/v2/pokemon-color/"
    data = requests.get(url)
    parsed_data = data.json()
    pokemon_types = parsed_data['results']
    for p_type in pokemon_types:
        url = ['results']['url']
    

    .. it'll print the resulting colour name and url which then has further data. I cant figure out how to pull more data from the urls and print that, rather than the url itself. i know how to separate the data that I need to get from the urls, but I dont know how to open those urls, so i can search and then print what I need. Anyone have an pointers or anything online to help me figure it out?


Comments

Advertisement