Forums

sqlite3

I want to store scrapped data (i.e. imdb ratings) into sqlite3 database. Not able to store values in ssqlite3 table as per the output of each iteration of the loop in the code below. Please help.

import urllib import re moviename=["tt0238936","tt1375666","tt1454468","tt2381249"]

i=0 while i<len(moviename):

  url="http://www.imdb.com/title/"+moviename[i]+"/?ref_=fn_al_tt_1"
  htmlfile=urllib.urlopen(url)
  htmltext=htmlfile.read()
  regex='<div class="titlePageSprite star-box-giga-star"> (.+?) </div>'
  pattern=re.compile(regex)
  rating=re.findall(pattern,htmltext)
  tags=re.findall('''<a href="(.+?)"''',htmltext,re.DOTALL)
  x=len(tags)
  print  moviename[i],"is=", x
  i+=1

What error message do you get (if any)?