From f8bc3023e93ec1ee55eed3591e8b3f32a7b065dc Mon Sep 17 00:00:00 2001 From: doubaniux Date: Fri, 28 Aug 2020 21:07:36 +0800 Subject: [PATCH] fix None value handling --- common/scraper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/scraper.py b/common/scraper.py index 125b03db..92903b62 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -64,7 +64,7 @@ def scrape_douban_book(url): pub_house = pub_house_elem[0].strip() if pub_house_elem else None pub_date_elem = content.xpath("//div[@id='info']//span[text()='出版年:']/following::text()") - pub_date = pub_date_elem[0].strip() if pub_date_elem else None + pub_date = pub_date_elem[0].strip() if pub_date_elem else '' year_month_day = RE_NUMBERS.findall(pub_date) if len(year_month_day) in (2, 3): pub_year = int(year_month_day[0])