Scrapy 无法让xpath选择下一步按钮

Scrapy 无法让xpath选择下一步按钮,scrapy,Scrapy,我正在尝试爬网这个gem网站: 发生了一些奇怪的事情,我不知道如何获取某些元素,如下一步按钮中的href 比如说, response.xpath('//section')生成: [<Selector xpath='//section' data='<section class="specimen-details">\n\t<...'>, <Selector xpath='//section' data='<section clas

我正在尝试爬网这个gem网站:

发生了一些奇怪的事情,我不知道如何获取某些元素,如
下一步
按钮中的
href

比如说,

response.xpath('//section')
生成:

[<Selector xpath='//section' data='<section class="specimen-details">\n\t<...'>,
 <Selector xpath='//section' data='<section class="specimen-related hidd...'>,
 <Selector xpath='//section' data='<section class="shows hidden-print">\n...'>,
 <Selector xpath='//section' data='<section class="blog hidden-print">\n ...'>,
 <Selector xpath='//section' data='<section class="navigation">\n        ...'>]
[,,
,
,
,
]

但是当我在控制台中查看时,我看到一个附加的
,它没有显示在那里,并且包含导航按钮。我不知道发生了什么事。感谢您的帮助和建议

获取下一页href的xpath是
//a[@rel=“next”]/@href

所以你基本上可以做到

response.xpath('//a[@rel=“next”]/@href').get()

或者使用css选择器

response.css('a[rel=“next”]::attr(href)').get()


get()方法适用于较新版本的scrapy,如果在您使用extract_first()时不起作用的话。

谢谢您的帮助!