【发布时间】:2017-08-17 01:58:10
【问题描述】:
我正在尝试使用 Scrapy 抓取以下链接下的页面。 http://nc.mofcom.gov.cn/channel/qytc2017/list.shtml?p_index=210000 当我试图抓取下一页时, nc.mofcom.gov.cn/channel/qytc2017/list.shtml?p_index=210000&page=2 我发现下一页的 href 是用 Javascript 编写的。 首先,我尝试使用下面的代码找到所有可能的。
def parse_item(self, response):
for pageNum in range(1, 10):
new_url = response.url + "&page=%d" % pageNum
yield Request(new_url, callback=self.parse_detailpage)
因为只有子页面,它不会例外;但是,我发现 nc.mofcom.gov.cn/channel/qytc2017/list.shtml?p_index=210000&page=7 和nc.mofcom.gov.cn/channel/qytc2017/list.shtml?p_index=210000&page=6 内容相同。确实,我还注意到有些页面有超过 10 个子页面,我无法继续抓取。任何人都可以给我一些想法吗?我没有 10 名声望,我可以提供超过 1 个链接和图片,我真的很抱歉。如果有人能提供帮助,我真的很感激。
【问题讨论】:
标签: javascript python scrapy web-crawler