Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit fe6688e

Browse files
committed
fix: first crawling will raise error
1 parent 9556b58 commit fe6688e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

spider/nCoV/spiders/dxy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @Author: zhanglei3
33
# @Date: 2020-04-08 09:08:13
44
# @Last Modified by: leafcoder
5-
# @Last Modified time: 2020-04-17 22:51:26
5+
# @Last Modified time: 2020-04-27 21:05:52
66

77
"""丁香园数据源"""
88

@@ -34,8 +34,8 @@ def parse(self, response):
3434
datetime.fromtimestamp(statistics['createTime'] / 1000.0))
3535
modifyTime = make_aware(
3636
datetime.fromtimestamp(statistics['modifyTime'] / 1000.0))
37-
prev_crawler = items.CrawlerItem.django_model.objects.all().order_by('-id')[1]
38-
if prev_crawler.modifyTime == modifyTime:
37+
qs = items.CrawlerItem.django_model.objects.all().order_by('-id')
38+
if qs.count() > 1 and qs[1].modifyTime == modifyTime:
3939
logger.info('Data does not change.')
4040
self.crawler.delete()
4141
self.crawler = None
@@ -66,6 +66,7 @@ def parse(self, response):
6666
country.pop('id', None)
6767
country['countryName'] = country.pop('provinceName', None)
6868
country['provinceName'] = ''
69+
country.pop('countryType')
6970
country.pop('cityName')
7071
country.pop('provinceId')
7172
country.pop('provinceName')

0 commit comments

Comments
 (0)