Unboundlocalerror: Local Variable 'items' Referenced Before Assignment
Possible Duplicate: convert list to string to insert into my sql in one row in python scrapy I am trying to write the data extracted from HTML pages directly to a MySQL database
Solution 1:
It looks like you have an indenting problem. The for index in range(len(items))
is part of the for site in sites
loop, right?
for site in sites:
items = [site.select('//h2').extract()]
item = [site.select('//h3').extract()]
meta = [site.select('//meta').extract()]
for index inrange (len( items)): # <-- make sure this has samestr = items[index] # level of indenting as previous lines
cur.execute("""Insert into h2_meta(h2) Values(%s)""",(str))
Post a Comment for "Unboundlocalerror: Local Variable 'items' Referenced Before Assignment"