I'm trying to use Python and BeautifulSoup to scrape some web info, iterate through it and then insert some pieces into a sqlite3 DB. But I keep coming up with this error:
File "/Users/Chris/Desktop/BS4/TBTfile.py", line 103, in TBTscrape c.execute(item) sqlite3.OperationalError: near "s": syntax error
This same code works fine on a very similar scraper and does not throw these errors. Here's the portion of it:
listicle.append("INSERT INTO headlines (heds, url, image_loc, time, source) VALUES ('" + TBTheadline + "', '" + TBTurl + "', '" + imageName + "', '" + TBTpostDate + "', '" + source + "')")
else:
print "TBT item already in database"
print listicle
for item in listicle:
c.execute(item)
conn.commit()
row = c.fetchall()
print "This has been inserted succcessfully: ", item
Aucun commentaire:
Enregistrer un commentaire