注册 登录
编程论坛 Python论坛

有位Python大佬可以给小弟解惑一下

刘腾龙 发布于 2021-05-17 20:45, 1185 次点击
这是判断当前也是否是最后一页不是的话就进入下一页继续爬取数据知道最后一页。我爬取的是这个网址:https://movie.
            nextLink = selector.xpath('//span[@class="next"]/link/@href').extract()

            if nextLink: #第十页是最后一页,没有下一页的链接
                nextLink = nextLink[0]
                print(nextLink)
                yield Request(self.start_urls[0] + nextLink)
0 回复
1