Ruby + Anemone Web Crawler:正则表达式匹配以一系列数字结尾的URL

假设我正在尝试抓取一个网站,跳过一个像这样结束的页面:

http://HIDDENWEBSITE.com/anonimize/index.php?page=press_and_news&subpage=20060117

我目前正在使用Ruby中的Anemone gem来构建爬虫。 我使用的是skip_links_like方法,但我的模式似乎永远不匹配。 我试图使其尽可能通用,因此它不依赖于子页面而只是=2105925 (数字)。

我试过/=\d+$//\?.*\d+$/ /=\d+$/但它似乎没有用。

这类似于跳过带有扩展名pdf的网页,来自在Anemone中抓取的zip,但我不能用数字而不是扩展来使其值得。

此外,在http://regexpal.com/上使用pattern =\d+$将成功匹配http://misc.com/test/index.php?page=news&subpage=20060118

编辑:

这是我的全部代码。 我想知道是否有人能够确切地看到错误。

 require 'anemone' ... Anemone.crawl(url, :depth_limit => 3, :obey_robots_txt => true) do |anemone| anemone.skip_links_like /\?.*\d+$/ anemone.on_every_page do |page| pURL = page.url.to_s puts "Now checking: " + pURL bestGuess[pURL] = match_freq( manList, page.doc.inner_text ) puts "Successfully checked" end end 

我的输出是这样的:

 ... Now checking: http://MISC.com/about_us/index.php?page=press_and_news&subpage=20110711 Successfully checked ... 

  Anemone.crawl(url, :depth_limit => 3, :obey_robots_txt => true, :skip_query_strings => true) do |anemone| anemone.on_every_page do |page| pURL = page.url.to_s puts "Now checking: " + pURL bestGuess[pURL] = match_freq( manList, page.doc.inner_text ) puts "Successfully checked" end end 

实际上/ /\?.*\d+$/有效:

 ~> irb > all systems are go wirble/hirb/ap/show < ruby-1.9.2-p180 :001 > "http://hiddenwebsite.com/anonimize/index.php?page=press_and_news&subpage=20060117".match /\?.*\d+$/ => #