Support Forums
Fetch data from a web page - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32)
+---- Thread: Fetch data from a web page (/showthread.php?tid=28714)



Fetch data from a web page - hami1981 - 09-05-2014

Hello!

I´d appreciate it if you could help me out.

I need to fetch air pollutant concentrations from the following site:

http://siga.jalisco.gob.mx/ramag/ImecasParticulasR.aspx

I tryed the following code, but, since the concentrations are not in the main html, I get nothing.


import urllib
import re

htmlfile = urllib.urlopen('The site above')

htmltext = htmlfile.read()

print htmltext

regex = '<div style="WIDTH:223.48mm;">(.+?)</div>'

pattern = re.compile(regex)


print pattern

con = re.findall(pattern, htmltext)


print con


RE: Fetch data from a web page - hami1981 - 09-05-2014

I tryied this just to see if I could retrieve something, but I only get an empty list.


import urllib
import re

htmlfile = urllib.urlopen('http://siga.jalisco.gob.mx/aire/tablasCon.html')

htmltext = htmlfile.read()

print htmltext

regex = '<div style="WIDTH:223.48mm;">(.+?)</div>'

pattern = re.compile(regex)


print pattern

con = re.findall(pattern, htmltext)


print con