modify class attrib selector
This commit is contained in:
parent
d1e3d99a76
commit
dc35f3f990
|
@ -14,11 +14,10 @@ class BjxpvSpider(scrapy.Spider):
|
|||
yield scrapy.Request(url, self.news_parse)
|
||||
|
||||
next_page = response.xpath('//a[contains(text(), "下一页")]')
|
||||
if next_page.attrib['class'] != 'disable':
|
||||
if next_page.attrib.get('class') != 'disable':
|
||||
url = next_page.attrib['href']
|
||||
yield response.follow(url, self.parse)
|
||||
|
||||
|
||||
def news_parse(self, response):
|
||||
news_item = NewsItem()
|
||||
news_item['website'] = '北极星太阳能光伏网'
|
||||
|
|
Loading…
Reference in New Issue
Block a user