Created
July 29, 2011 16:44
-
-
Save martinth/1114198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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