From ee7f33c4c9b71d43fbfa18b9ab75b0bcecd2317b Mon Sep 17 00:00:00 2001 From: link_1999 <1402246900@qq.com> Date: Thu, 7 Apr 2022 18:49:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20'dagongPro'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dagongPro/items.py | 1 + dagongPro/pipelines.py | 2 +- dagongPro/settings.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dagongPro/items.py b/dagongPro/items.py index 3f052f2..3f6e9a4 100644 --- a/dagongPro/items.py +++ b/dagongPro/items.py @@ -11,3 +11,4 @@ class DagongwangproItem(scrapy.Item): content = scrapy.Field() date = scrapy.Field() src = scrapy.Field() + author = scrapy.Field() diff --git a/dagongPro/pipelines.py b/dagongPro/pipelines.py index d4baf33..1ac2c26 100644 --- a/dagongPro/pipelines.py +++ b/dagongPro/pipelines.py @@ -34,7 +34,7 @@ class mysqlPileLine(object): self.cursor = self.conn.cursor() try: - self.cursor.execute('insert into junshi_news values("%s", "%s", "%s", "%s")'%(item['title'], item['date'], item['content'], item['src'])) + self.cursor.execute('insert into junshi_news values("%s", "%s", "%s", "%s", "%s")'%(item['title'], item['date'], item['author'], item['content'], item['src'])) self.conn.commit() except Exception as e: print(e) diff --git a/dagongPro/settings.py b/dagongPro/settings.py index 2e65af0..af30dbc 100644 --- a/dagongPro/settings.py +++ b/dagongPro/settings.py @@ -64,7 +64,7 @@ DOWNLOADER_MIDDLEWARES = { # Configure item pipelines # See https://docs.scrapy.org/en/latest/topics/item-pipeline.html ITEM_PIPELINES = { - 'dagongwangPro.pipelines.DagongwangproPipeline': 300, + # 'dagongwangPro.pipelines.DagongwangproPipeline': 300, 'dagongwangPro.pipelines.mysqlPileLine': 301, }