我正在尝试使用Scrubyt从这个页面http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php?section=events中获取详细信息。我已经设法从列表中获得了标题和详细URL,但我不能使用next_page让抓取器转到下一个页面。我假设这是因为我没有为下一页链接使用正确的模式。我试过字符串"Next Page",我也试过XPath。还有其他想法吗?
代码如下:
require 'rubygems'
require 'scrubyt'
nuffield_data = Scrubyt::Extractor.define do
fetch 'http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php?section=events'
event do
title 'The Coast of Mayo'
#url "href", :type => :attribute
link_url
end
next_page "Next Page", :limit => 2
end
nuffield_data.to_xml.write($stdout,1)发布于 2008-10-04 10:34:52
尝试使用稍有不同的URL:
fetch 'http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php'在网址末尾的"?section=events“查询似乎有问题。
当它查找下一个页面时,它会尝试返回这个URL:
http://www.nuffieldtheatre.co.uk/cn/events/?pageNum_rsSearch=1&totalRows_rsSearch=39§ion=events
而不是:
http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php?pageNum_rsSearch=1&totalRows_rsSearch=39§ion=events
删除URL末尾的查询字符串似乎可以解决这个问题--您可能希望将其作为一个bug进行归档。
https://stackoverflow.com/questions/168868
复制相似问题