From b937e9b21af5a3e4c2f10952606dbf25a4b02510 Mon Sep 17 00:00:00 2001 From: Wayne Lui Date: Mon, 27 Feb 2023 17:29:12 +0800 Subject: [PATCH] Fix a type error and optimize the method. --- scrapinglib/fanza.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scrapinglib/fanza.py b/scrapinglib/fanza.py index e8b1917..e9b25c3 100644 --- a/scrapinglib/fanza.py +++ b/scrapinglib/fanza.py @@ -49,15 +49,13 @@ class Fanza(Parser): self.detailurl = url + fanza_search_number url = "https://www.dmm.co.jp/age_check/=/declared=yes/?"+ urlencode({"rurl": self.detailurl}) self.htmlcode = self.getHtml(url) - if "Sorry! This content is not available in your region." in self.htmlcode: - continue - if self.htmlcode != 404: + if self.htmlcode != 404 \ + and 'Sorry! This content is not available in your region.' not in self.htmlcode: self.htmltree = etree.HTML(self.htmlcode) - break - if self.htmlcode == 404: - return 404 - result = self.dictformat(self.htmltree) - return result + if self.htmltree is not None: + result = self.dictformat(self.htmltree) + return result + return 404 def getNum(self, htmltree): # for some old page, the input number does not match the page