Skip to content

Commit 48328d1

Browse files
authored
Merge pull request #583 from zangwill/patch-1
解决 'NoneType' object has no attribute 'xpath'
2 parents 287e93f + e94535b commit 48328d1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

weibo_spider/parser/page_parser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def __init__(self, cookie, user_config, page, filter):
4444
is_exist = ''
4545
for i in range(3):
4646
self.selector = handle_html(self.cookie, self.url)
47-
info = self.selector.xpath("//div[@class='c']")
48-
if info is None or len(info) == 0:
49-
continue
50-
is_exist = info[0].xpath("div/span[@class='ctt']")
47+
if self.selector:
48+
info = self.selector.xpath("//div[@class='c']")
49+
if info is None or len(info) == 0:
50+
continue
51+
is_exist = info[0].xpath("div/span[@class='ctt']")
5152
if is_exist:
5253
PageParser.empty_count = 0
5354
break

0 commit comments

Comments
 (0)