I am creating this program. But I can't get it to insert data into the sqlite3 database.
class Spider(HTMLParser):
def __init__(self, url):
HTMLParser.__init__(self)
req = urlopen(url)
self.feed(req.read())
def handle_starttag(self, tag, attrs):
if tag == 'a' and attrs:
print "Found link => %s" % attrs[0][1]
cursor.execute("INSERT INTO queue VALUE((?), (?), (?))",(None, attrs[0][0], attrs[0][1]))
connection.commit()
if __name__ == '__main__':
Spider(starturl)
I think the problem is in the following line.
cursor.execute("INSERT INTO queue VALUE((?), (?), (?))",(None, attrs[0][0], attrs[0][1]))
Thanks in advance!