上传文件至 'dagongPro'

新增newsid管道
This commit is contained in:
link_1999 2022-04-08 22:29:15 +08:00
parent 348e30dbd7
commit dcae430498
1 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@
from itemadapter import ItemAdapter from itemadapter import ItemAdapter
import pymysql import pymysql
# 本地存储管道
class DagongwangproPipeline: class DagongwangproPipeline:
def process_item(self, item, spider): def process_item(self, item, spider):
@ -24,7 +24,7 @@ class DagongwangproPipeline:
return item return item
# 数据库存储管道
class mysqlPileLine(object): class mysqlPileLine(object):
conn = None conn = None
cursor = None cursor = None
@ -34,7 +34,7 @@ class mysqlPileLine(object):
self.cursor = self.conn.cursor() self.cursor = self.conn.cursor()
try: try:
self.cursor.execute('insert into junshi_news values("%s", "%s", "%s", "%s", "%s")'%(item['title'], item['date'], item['author'], item['content'], item['src'])) self.cursor.execute('insert into js_news values("%s", "%s", "%s", "%s", "%s")'%(item['title'], item['date'], item['author'], item['content'], item['src']))
self.conn.commit() self.conn.commit()
except Exception as e: except Exception as e:
print(e) print(e)