I am trying to get the latitude and longitude of the ISS from the site:
https://api.wheretheiss.at/v1/satellites/25544
I have managed to work out I need to use urllib2, but I can't install it using pip, I get the error:
Could not find a version that satisfies the requirement urllib2 <from the version: >
No matching distribution found for urllib2
Could someone tell me how I can install urllib2 and also the code I would need to use to get the latitude and longitude? Thanks.
Python3.4 includes
urllib(noturllib2) by default. To use it, simplyimport urllib.Also, be aware that you should follow
urllibdocs for Python3.4 because things have been moved and are in a different place from where you would expect them if you were looking aturllib2, which was for Python2.For instance, to request a url using
urllib, you would do the following:However, it is recommended (even by the
urllibdocumentation) that you use requests instead:Then, to use requests, you can do the following:
Finally, your endpoint up there is returning JSON, so using
requestsyou can access those values in the following way: