Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby+;海葵网络爬虫:正则表达式匹配以一系列数字结尾的URL_Ruby_Regex_Ruby On Rails 3_Web Crawler_Anemone - Fatal编程技术网

Ruby+;海葵网络爬虫:正则表达式匹配以一系列数字结尾的URL

Ruby+;海葵网络爬虫:正则表达式匹配以一系列数字结尾的URL,ruby,regex,ruby-on-rails-3,web-crawler,anemone,Ruby,Regex,Ruby On Rails 3,Web Crawler,Anemone,假设我试图爬过一个网站,跳过一个以这样结尾的页面: 我目前正在使用Ruby中的海葵宝石来构建爬虫程序。我使用的是类似跳过链接的方法,但我的模式似乎从不匹配。我试图使其尽可能通用,因此它不依赖于子页面,而只是=2105925(数字) 我试过/=\d+$/和/\?.*\d+$/但似乎不起作用 这与类似,但我不能用数字代替扩展名 另外,使用模式=\d+$测试将成功匹配http://misc.com/test/index.php?page=news&subpage=20060118 编辑: 这是我的全

假设我试图爬过一个网站,跳过一个以这样结尾的页面:

我目前正在使用Ruby中的海葵宝石来构建爬虫程序。我使用的是类似跳过链接的方法,但我的模式似乎从不匹配。我试图使其尽可能通用,因此它不依赖于子页面,而只是
=2105925
(数字)

我试过
/=\d+$/
/\?.*\d+$/
但似乎不起作用

这与类似,但我不能用数字代替扩展名

另外,使用模式
=\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
...

实际上,
/\?.*\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+$/
 => #<MatchData "?page=press_and_news&subpage=20060117"> 
~>irb
>所有系统均为无线/hirb/ap/show<
ruby-1.9.2-p180:001>“http://hiddenwebsite.com/anonimize/index.php?page=press_and_news&subpage=20060117“.match/\?*\d”+$/
=> # 

否则,这一定是我的代码有问题。我似乎无法让它工作。这工作非常好,谢谢!虽然,它有点跳跃沉重!一些有效页面显示为查询字符串。我应该重写类中的代码吗?当我打开“删除查询字符串”时,它会删除和。我想让它爬行前者,但不是后者。我只希望它跳过结尾有数字的页面。
  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