Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
data = urlopen('''http://www.hydro.eaufrance.fr/stations/O7502510&procedure=tousmois''').read()
soup = BeautifulSoup(data)
table = soup.find('table', {'summary': "valeurs mensuelles et annuelles"})
for tr in table.findAll('tr'):
line = []
for td in tr.findAll('td'):
try:
line.append(td.find('input', {'name':'value'})['value'])
except TypeError:
line.append(td.text)
print ','.join(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment