0

我正在尝试使用 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)
4

1 回答 1

2

尝试使用稍微不同的 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

代替:

http://www.nuffieldtheatre.co.uk/cn/events/event_listings.php?pageNum_rsSearch=1&totalRows_rsSearch=39§ion=events

删除 URL 末尾的查询字符串似乎可以解决此问题 - 您可能希望将此作为错误归档。

于 2008-10-04T10:34:51.870 回答