Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MysqlPipeline(object):
- def open_spider(self, spider):
- self.con = pymysql.connect(host="localhost", user="root", password="password", db="articals", port=3306)
- self.cur = self.con.cursor()
- def process_item(self, item, spider):
- str = "insert into one(title, content) values({}, {})".format(item['title'], item['content'])
- self.cur.execute(str)
- self.con.commit()
- def close_spider(self, spider):
- self.con.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement