如何与Scrubyt建立“下一页”链接
我正在尝试使用Scrubyt从这个页面获取详细信息http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php?section=events 。 我已经设法从列表中获取标题和详细信息URL,但我无法使用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)
尝试使用稍微不同的URL:
fetch 'http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php'
scrubyt似乎在URL末尾有“?section = events”查询问题。
当它查找下一页时,它会尝试返回此URL:
http://www.nuffieldtheatre.co.uk/cn/events/?pageNum_rsSearch=1&totalRows_rsSearch=39§ion=events
代替:
删除URL末尾的查询字符串似乎解决了这个问题 – 您可能希望将此文件作为错误提交。