这是什么情况呀 有人能帮帮我解答一下嘛 万分感谢
# 解析当前页面
for weibo in self.parse_weibo(response):#报错
self.check_environment()
yield weibo
next_url = response.xpath(
'//a[@class="next"]/@href').extract_first()
-------------------------------------------------------------------------------------
weibo['bid'] = sel.xpath( #报错
'.//div[@class="from"]/a[1]/@href').extract_first(
).split('/')[-1].split('?')[0]
weibo['user_id'] = info[0].xpath(
'div[2]/a/@href').extract_first().split('?')[0].split(
'/')[-1]
weibo['screen_name'] = info[0].xpath(
'div[2]/a/@nick-name').extract_first()
txt_sel = sel.xpath('.//p[@class="txt"]')[0]
报了这样的错误
File "D:\系统默认\download\weibo-search-master\weibo\spiders\search.py", line 107, in parse
for weibo in self.parse_weibo(response):
File "D:\系统默认\download\weibo-search-master\weibo\spiders\search.py", line 356, in parse_weibo
weibo['bid'] = sel.xpath(
AttributeError: 'NoneType' object has no attribute 'split'
要怎么解决呀T T
下面是一个简单的例子,你可以参考一下:
text = sel.xpath('.//div[@class="text"]/text()')
if text:
text = text.extract_first().strip().split(' ')[0]