I want to convert a list object into a string and insert this string as one row in mysql database. Can someone please provide a solution to this. My code looks like this:
def parse(self, response):
hxs = HtmlXPathSelector(response)
sites = hxs.select('//ul/li')
for site in sites:
con = mysqldb.connect(
host="localhost",
user="dreamriks",
passwd="dreamriks",
db="scraped_data"
)
cur = con.cursor()
quest = site.select('//h2').extract()
ans = site.select('//h3').extract()
meta = site.select('//meta').extract()
cur.execute("""Insert into scraped_data(h2, h3, meta) Values(%s,%s,%s)""",(quest,ans,meta))
con.commit()
con.close()
The code above gives the following error:
File "/usr/local/lib/python2.7/dist-packages/Scrapy-0.14.0.2841-py2.7.egg/scrapy/spider.py", line 62, in parse
raise NotImplementedError
exceptions.NotImplementedError:
Can someone help me with this error. I am stuck at this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…