jeudi 19 janvier 2017

Scraping data from a website using Python 2

I am trying to scrape data from the stock market but I keep getting nothing when I print out the data.

import urllib
import re



htmlfile = urllib.urlopen("http://ift.tt/1dQYIyD")

htmltext = htmlfile.read()

regex = '<span class="Fw(500) Pstart(10px) Fz(24px) C($dataRed)" data-reactid="271">-0.21 (-0.18%)</span>'

pattern = re.compile(regex)

price = re.findall(pattern,htmltext)

print price




Aucun commentaire:

Enregistrer un commentaire