I want to download a list of csv with a python script.
http://meteo.navarra.es/estaciones/descargardatos_estacion.cfm?IDEstacion=251
I've used this code to locate the file urls
import urllib.request as urllib2
from bs4 import BeautifulSoup
# Fetch URL
url =
'http://meteo.navarra.es/estaciones/descargardatos_estacion.cfm?
IDEstacion=251'
request = urllib2.Request(url)
request.add_header('Accept-Encoding', 'utf-8')
# Response has UTF-8 charset header,
# and HTML body which is UTF-8 encoded
response = urllib2.urlopen(request)
# Parse with BeautifulSoup
soup = BeautifulSoup(response,"html.parser")
print(soup)
Those CSVs urls are inside a javascripts script
<script type="text/javascript">
<!--
var d = new dTree('d');
d.add(0,-1,'<b>Ficheros de datos</b>');
d.add(1,0,'AncÃn INTIA','','','','/js/dtree/img/folder.gif');
d.add(10,1,'Datos diarios','','','','/js/dtree/img/folder.gif');
d.add(1000,10,'AncÃn INTIA_2001.csv','/_data/datos_estaciones/estacion_251/datos diarios/ancÃn intia_2001.csv');
d.add(1001,10,'AncÃn INTIA_2002.csv','/_data/datos_estaciones/estacion_251/datos diarios/ancÃn intia_2002.csv');
d.add(1002,10,'AncÃn INTIA_2003.csv','/_data/datos_estaciones/estacion_251/datos diarios/ancÃn intia_2003.csv');
d.add(1003,10,'AncÃn INTIA_2004.csv','/_data/datos_estaciones/estacion_251/datos diarios/ancÃn intia_2004.csv');
-->
I've tried to use request and soup to find the dTree but i cant get to access the tree attributes.