Unable to parse data from weather website
<p>Hey i want to parse weather data from the following website: <a href="http://www.indiaweather.gov.in" rel="nofollow">http://www.indiaweather.gov.in</a></p>

<p>If you observe you have a search bar which lets you enter any indian city's name and when you hit go you end up on a page with the weather data for that city.</p>

<p>Could anyone help me with a script which will allow me to enter the city's name, and will display the city's weather data?</p>

<p>I didn't know how to parse the data.</p>

<p>Thanks!</p>

<p>You could use Beautiful Soup! to get your desired data between specific html tags. If you want to do it yourself you could post your data by calling the site's api. first install requests. <code>pip install requests</code> then</p>

<pre><code>import re
import requests


# the data is between align="left"&gt;&lt;font size="3px"&gt; and &lt;/font&gt; in each specific part so we use re to find it
def find_data(line):
    return re.search('align="left"&gt;&lt;font size="3px"&gt;(.*?)&lt;/font&gt;', line).group(1)

params = {
    'tags': city_name,
    'submit': 'Go'
}

response = requests.post('http://www.indiaweather.gov.in/?page_id=942', data=params).content.splitlines()

try:
    current_temp = find_data(response[357])
    max_temp = find_data(response[362])
    min_temp = find_data(response[369])
    last_day_rainfall = find_data(response[376])
    current_wind_direction = find_data(response[382])
    current_wind_speed = find_data(response[389])
    current_dew_point = find_data(response[396])
    current_sea_level_pressure = find_data(response[403])
    print(current_temp, max_temp, min_temp, last_day_rainfall, current_wind_direction, current_wind_speed,
          current_dew_point, current_sea_level_pressure)

except IndexError:
    print('No Info Found For %s' % params['tags'])
</code></pre>

python html parsing beautifulsoup weather