- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
在下面的示例中,我希望 anemone 仅在根 URL (example.com) 上执行。我不确定是否应该应用 on_page_like 方法,如果是的话我需要什么模式。
require 'anemone'
Anemone.crawl("http://www.example.com/") do |anemone|
anemone.on_pages_like(???) do |page|
# some code to execute
end
end
最佳答案
require 'anemone'
Anemone.crawl("http://www.example.com/", :depth_limit => 1) do |anemone|
# some code to execute
end
您还可以在选项哈希中指定以下内容,以下是默认值:
# run 4 Tentacle threads to fetch pages
:threads => 4,
# disable verbose output
:verbose => false,
# don't throw away the page response body after scanning it for links
:discard_page_bodies => false,
# identify self as Anemone/VERSION
:user_agent => "Anemone/#{Anemone::VERSION}",
# no delay between requests
:delay => 0,
# don't obey the robots exclusion protocol
:obey_robots_txt => false,
# by default, don't limit the depth of the crawl
:depth_limit => false,
# number of times HTTP redirects will be followed
:redirect_limit => 5,
# storage engine defaults to Hash in +process_options+ if none specified
:storage => nil,
# Hash of cookie name => value to send with HTTP requests
:cookies => nil,
# accept cookies from the server and send them back?
:accept_cookies => false,
# skip any link with a query string? e.g. http://foo.com/?u=user
:skip_query_strings => false,
# proxy server hostname
:proxy_host => nil,
# proxy server port number
:proxy_port => false,
# HTTP read timeout in seconds
:read_timeout => nil
我个人的经验是 Anemone 速度不是很快并且有很多角落案例。缺少文档(如您所见),并且作者似乎没有维护该项目。 YMMV。我试过 Nutch很快但没有玩那么多但它似乎更快。没有基准,抱歉。
关于ruby-on-rails - 如何 "crawl"只有根 URL 与 Anemone ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227555/
使用 Anemone,我在尝试使用 MongoDB 时遇到此错误: gems/anemone-0.7.2/lib/anemone/storage.rb:28:in `MongoDB': uniniti
我们可以用 Anemone 抓取一个漏洞网站(例如:https://stackoverflow.com/),但是如果我只想关注某个文件夹怎么办(例如:https://stackoverflow.com
我不明白如何使用 Anemone 的触手部分。如果我对它的解释是正确的,我觉得我可以用它来从根目录中清除特定的页面深度。 Anemone.crawl(start_url) do |anemone|
代码: require 'anemone' Anemone.crawl("http://www.example.com/") do |anemone| anemone.on_every_page
我正在使用 Anemone 。我如何抓取子域?例如,如果我有网站 www.abc.com,我的抓取工具也应该抓取 support.abc.com 或 blah.abc.com。我正在使用 Ruby 1
我通过以下方式使用 Anemone gem: 访问第一个 url(种子),将页面内容保存到数据库,并将该页面的所有链接也保存到数据库(所有尚未在数据库中的链接) 从数据库中加载下一个链接,再次保存其内
我正在使用 Anemone爬取一个域,它工作正常。 启动抓取的代码如下所示: require 'anemone' Anemone.crawl("http://www.example.com/") do
我在 ruby 上运行一个带有 Anemone 的网络抓取工具,当我的服务器访问需要登录的页面时,我的服务器出现了一些问题。 所有页面的 url 中都有一个短语,例如“account”,我希望程序
我有一个抓取设置: require 'anemone' Anemone.crawl("http://www.website.co.uk", :depth_limit => 1) do |anemone
我希望将在线的数万页政府数据(在数千个文件夹中)拼凑起来,并将其全部放入一个文件中。为了加快这个过程,我想我会先把网站下载到我的硬盘上,然后再用像 Anemone + Nokogiri 这样的东西来抓
现在,我正在使用 Anemone 执行以下操作: Anemone.crawl("http://www.findbrowsenodes.com/", :delay => 3) do |anemone|
我正在努力进行爬网,但在我对整个网站进行爬网之前,我想对大约几个页面进行一次测试。所以我在想像下面这样的东西会起作用,但我一直收到 nomethoderror.... Anemone.crawl(se
我的起始页为 http://www.example.com/startpage它有 1220 个列表,按标准方式分页,例如每页 20 个结果。 我有代码可以解析结果的第一页,并跟踪在其 url 中包含
我正在创建某种网络爬虫,当我使用没有存储空间的 Anemone 来爬网网站时,它最终会因内存问题而崩溃。 所以我安装了 Redis、redis-rb 等,并更改了我的代码以使用 redis 存储。现在
我想将 URL on_pages_like 保存为特定匹配项。 Anemone 正在做它的事情,并且正在创建存储 URL 的记录,但是: 我想使用 find_or_create_by_url 而不是
我需要从站点的所有页面收集所有“标题”。 站点具有 HTTP 基本身份验证配置。 没有授权我接下来做: require 'anemone' Anemone.crawl("http://example.
在下面的示例中,我希望 anemone 仅在根 URL (example.com) 上执行。我不确定是否应该应用 on_page_like 方法,如果是的话我需要什么模式。 require 'an
我正在使用 anemone gem(Ruby- 1.8.7 和 Rails 3.1.1)开发爬虫。我应该如何从抓取/下载中跳过带有扩展名 pdf、doc、zip 等的网页。 最佳答案 ext = %w
我最近开始学习网络爬虫,我用 Ruby 构建了一个示例爬虫,Anemone , 和 Mongodb用于存储。我正在一个可能包含数十亿个链接的大型公共(public)网站上测试爬虫。 crawler.r
假设我正在尝试抓取一个网站并跳过这样结束的页面: http://HIDDENWEBSITE.com/anonimize/index.php?page=press_and_news&subpage=20
我是一名优秀的程序员,十分优秀!