What python libraries can tell me approximate location and time zone given an IP address?
https://freegeoip.net/; python sample below.
<span class="kwd">import</span><span class="pln"> requests FREEGEOPIP_URL </span><span class="pun">=</span> <span class="str">'http://freegeoip.net/json/'</span><span class="pln"> SAMPLE_RESPONSE </span><span class="pun">=</span> <span class="str">"""{ "ip":"108.46.131.77", "country_code":"US", "country_name":"United States", "region_code":"NY", "region_name":"New York", "city":"Brooklyn", "zip_code":"11249", "time_zone":"America/New_York", "latitude":40.645, "longitude":-73.945, "metro_code":501 }"""</span> <span class="kwd">def</span><span class="pln"> get_geolocation_for_ip</span><span class="pun">(</span><span class="pln">ip</span><span class="pun">):</span><span class="pln"> url </span><span class="pun">=</span> <span class="str">'{}/{}'</span><span class="pun">.</span><span class="pln">format</span><span class="pun">(</span><span class="pln">FREEGEOPIP_URL</span><span class="pun">,</span><span class="pln"> ip</span><span class="pun">)</span><span class="pln"> response </span><span class="pun">=</span><span class="pln"> requests</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">url</span><span class="pun">)</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">raise_for_status</span><span class="pun">()</span> <span class="kwd">return</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">json</span><span class="pun">(</span>