【发布时间】:2019-01-06 11:36:39
【问题描述】:
我正在尝试使用scrapy 抓取一个分页位于符号“#”后面的网站。不知何故,这让 scrapy 忽略了该字符背后的所有内容,并且它总是只会看到第一页。
例如:
如果您手动输入问号,网站将加载第 1 页
scrapy 的统计数据告诉我它获取了第一页:
调试:已爬网 (200) http://www.rolex.de/de/watches/datejust/m126334-0014.html>(参考: http://www.rolex.de/de/watches/find-rolex.html)
我的爬虫是这样的:
start_urls = [
'http://www.rolex.de/de/watches/find-rolex.html#g=1',
'http://www.rolex.de/de/watches/find-rolex.html#g=0&p=2',
'http://www.rolex.de/de/watches/find-rolex.html#g=0&p=3',
]
rules = (
Rule(
LinkExtractor(allow=['.*/de/watches/.*/m\d{3,}.*.\.html']),
callback='parse_item'
),
Rule(
LinkExtractor(allow=['.*/de/watches/find-rolex(/.*)?\.html#g=1(&p=\d*)?$']),
follow=True
),
)
如何让 scrapy 忽略 url 中的 # 并访问给定的 URL?
【问题讨论】:
-
打印结果页面的源代码并查看 HTML 是否可用或您需要的数据是否正在 AJAX 上加载
标签: scrapy