parent
348e30dbd7
commit
dcae430498
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue