python scrapy 如何获取当前页面url
3 回答

一只甜甜圈
TA贡献1836条经验 获得超5个赞
你好,在response中有url的信息,你可用下面的代码:
def parse(self, response):
print "URL: " + response.request.url

30秒到达战场
TA贡献1828条经验 获得超6个赞
爬虫跟踪下一页的方法是自己模拟点击下一页连接,然后发出新的请求。请看:
item1 = Item()
yield item1
item2 = Item()
yield item2
req = Request(url='下一页的链接', callback=self.parse)
yield req
注意使用yield时不要用return语句。
添加回答
举报
0/150
提交
取消