Retrieving the correct .json for wunderground
<p>So far I have produced the following code:</p>

<pre><code>import requests

def weatherSearch():
    Search = raw_input('Enter your location: ')
    r = requests.get("http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/{}.json".format(Search))
    weatherData = r.json()
    print weatherData

weatherSearch()
</code></pre>

<p>For example, if <code>Search</code> was set to <code>London</code>, it would produce:</p>

<p><a href="http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/London.json" rel="nofollow">http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/London.json</a></p>

<p>However, this .json doesn't contain the temperature which is what I'm trying to find: <code>"temp_c":</code></p>

<p>Whereas on the following link, <code>"temp_c":</code> can be found:</p>

<p><a href="http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/CA/San_Francisco.json" rel="nofollow">http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/CA/San_Francisco.json</a></p>

<p>I'm struggling to understand what I'm doing wrong in order to retrieve the weather data.</p>

<p>Looks like your query returns a list of possible matches, each of which has an <code>l</code> key which contains a link. Using that link brings you back the full data for that location. So, for instance, the full data for London, UK is at <a href="http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/zmw:00000.1.03772.json" rel="nofollow">http://api.wunderground.com/api/a8c3e5ce8970ae66/conditions/q/zmw:00000.1.03772.json</a>.</p>

python json python-2.7 python-requests