Nutch项目配置1---内部网搜索(原)

本文介绍如何配置和部署Nutch爬虫系统,包括环境搭建步骤、配置文件详解及在Tomcat上的运行方法。

http://lucene.apache.org/nutch/tutorial8.html 有如下的介绍:

Requirements

  1. Java 1.4.x, either from Sun or IBM on Linux is preferred. Set NUTCH_JAVA_HOME to the root of your JVM installation.
  2. Apache's Tomcat 4.x.
  3. On Win32, cygwin , for shell support. (If you plan to use Subversion on Win32, be sure to select the subversion package when you install, in the "Devel" category.)
  4. Up to a gigabyte of free disk space, a high-speed connection, and an hour or so.

所以需要的准备工作如下:

1、下载nutch,使用最新的0.9版本,放在D:\nutch\nutch-0.9下;

2、在环境变量中设置NUTCH_JAVA_HOME为jdk的安装路径;

3、安装tomcat服务器,不作介绍;

4、因为是在windows环境下,所以需要下载安装cygwin来运行shell command。

准备工作完毕。

Getting Started

First, you need to get a copy of the Nutch code. You can download a release from http://lucene.apache.org/nutch/release/ . Unpack the release and connect to its top-level directory. Or, check out the latest source code from subversion and build it with Ant .

Try the following command:

bin/nutch

This will display the documentation for the Nutch command script.

这部分工作有如下几步:

1、运行cygwin

安装完成cygwin后运行,执行命令:

cd d:nutch

cd nutch-0.9

cygwin所示的当前目录为:

/cygdrive/d/nutch/nutch-0.9

在此目录下执行命令:bin/nutch,如果正确的话,会有Usage:nutch COMMAND提示

Intranet: Configuration

To configure things for intranet crawling you must:

  1. Create a directory with a flat file of root urls. For example, to crawl the nutch site you might start with a file named urls/nutch containing the url of just the Nutch home page. All other Nutch pages should be reachable from this page. The urls/nutch file would thus contain:
    http://lucene.apache.org/nutch/
    
  2. Edit the file conf/crawl-urlfilter.txt and replace MY.DOMAIN.NAME with the name of the domain you wish to crawl. For example, if you wished to limit the crawl to the apache.org domain, the line should read:
    +^http://([a-z0-9]*\.)*apache.org/
    
    This will include any url in the domain apache.org .
  3. Edit the file conf/nutch-site.xml , insert at minimum following properties into it and edit in proper values for the properties:
<property>
  <name>http.agent.name</name>
  <value></value>
  <description>Our HTTP 'User-Agent' request header.</description>
</property>

<property>
  <name>http.robots.agents</name>
  <value>*</value>
  <description>The agent strings we'll look for in robots.txt files,
  comma-separated, in decreasing order of precedence.</description>
</property>

<property>
  <name>http.agent.description</name>
  <value></value>
  <description>Further description of our bot- this text is used in
  the User-Agent header.  It appears in parenthesis after the agent name.
  </description>
</property>

<property>
  <name>http.agent.url</name>
  <value></value>
  <description>A URL to advertise in the User-Agent header.  This will
   appear in parenthesis after the agent name.
  </description>
</property>

<property>
  <name>http.agent.email</name>
  <value></value>
  <description>An email address to advertise in the HTTP 'From' request
   header and User-Agent header.</description>
</property>
      


对于第一条应在d:\nutch\nutch-0.9下建文件夹urls,在此文件夹下建文本文件nutch.txt,其中的内容为:http://lucene.apache.org/nutch/

对于第二条,打开conf/crawl-urlfilter.txt  ,找到MY.DOMAIN.NAME  ,修改为:

+^http://([a-z0-9]*\.)*apache.org/

对于第三条,此次实验使用nutch-default.xml, 修改如下属性:

http.agent.name

http.robots.agents
http.agent.description
http.agent.url
http.agent.email
http.agent.version

例如:

 

<property>
  <name>http.agent.name</name>
  <value>NutchCVS</value>
  <description>Our HTTP 'User-Agent' request header.</description>
</property>

<property>
  <name>http.robots.agents</name>
  <value>*</value>
  <description>The agent strings we'll look for in robots.txt files,
  comma-separated, in decreasing order of precedence.</description>
</property>

<property>
  <name>http.agent.description</name>
  <value>Nutch</value>
  <description>Further description of our bot- this text is used in
  the User-Agent header.  It appears in parenthesis after the agent name.
  </description>
</property>

<property>
  <name>http.agent.url</name>
  <value>http://lucene.apache.org/nutch/</value>
  <description>A URL to advertise in the User-Agent header.  This will
   appear in parenthesis after the agent name.
  </description>
</property>

<property>
  <name>http.agent.email</name>
  <value>nutch-agent@lucene.apache.org</value>
  <description>An email address to advertise in the HTTP 'From' request
   header and User-Agent header.</description>
</property>

修改完成后保存。

Intranet: Running the Crawl

Once things are configured, running the crawl is easy. Just use the crawl command. Its options include:

  • -dir dir names the directory to put the crawl in.
  • -threads threads determines the number of threads that will fetch in parallel.
  • -depth depth indicates the link depth from the root page that should be crawled.
  • -topN N determines the maximum number of pages that will be retrieved at each level up to the depth.

For example, a typical call might be:

bin/nutch crawl urls -dir crawl -depth 3 -topN 50

Typically one starts testing one's configuration by crawling at shallow depths, sharply limiting the number of pages fetched at each level (-topN ), and watching the output to check that desired pages are fetched and undesirable pages are not. Once one is confident of the configuration, then an appropriate depth for a full crawl is around 10. The number of pages per level (-topN ) for a full crawl can be from tens of thousands to millions, depending on your resources.

Once crawling has completed, one can skip to the Searching section below.

此处只需运行如下命令即可:

bin/nutch crawl urls -dir crawled-depth 3 -topN 50 >&crawl.log

运行完成后,会生成crawled文件夹和crawl.log日志文件。

在日志文件中会发现抛pdf文件错误,那是因为默认情况下不支持对pdf文件的索引,要想对pdf文件也进行正确的索上,找到nutch-default.xml中的plugin.includes属性,添加上pdf,即为parse-(text|html|js|pdf)。

crawled中包含有segment, linkdb, indexed, index, crawldb文件夹。

到此为止,索引数据准备完毕。

下面是如何在tomcat中运行。

将nutch-0.9.war拷到tomcat的webapps目录下,并改名为nutch.war;

进入conf\Catalina\localhost目录下,创建文件nutch.xml,内容如下:

Context path="/nutch" debug="0" privileged="true"  /contect

 

 

启运tomcat;

进入解压后的webapps\nutch\WEB-INF\classes目录,将nutch-default.xml的search.dir设置为D:\nutch\nutch-0.9\crawled;

打开浏览器,运行http://localhost:8080/ nutch;

现就可以进行搜索了,输入apache,就可以查询得到相关的结果。

 

 

 

源码来自:https://pan.quark.cn/s/a3a3fbe70177 AppBrowser(Application属性查看器,不需要越狱! ! ! ) 不需要越狱,调用私有方法 --- 获取完整的已安装应用列表、打开和删除应用操作、应用运行时相关信息的查看。 支持iOS10.X 注意 目前AppBrowser不支持iOS11应用查看, 由于iOS11目前还处在Beta版, 系统API还没有稳定下来。 等到Private Header更新了iOS11版本,我也会进行更新。 功能 [x] 已安装的应用列表 [x] 应用的详情界面 (打开应用,删除应用,应用的相关信息展示) [x] 应用运行时信息展示(LSApplicationProxy) [ ] 定制喜欢的字段,展示在应用详情界面 介绍 所有已安装应用列表(应用icon+应用名) 为了提供思路,这里只用伪代码,具体的私有代码调用请查看: 获取应用实例: 获取应用名和应用的icon: 应用列表界面展示: 应用列表 应用运行时详情 打开应用: 卸载应用: 获取info.plist文件: 应用运行时详情界面展示: 应用运行时详情 右上角,从左往右第一个按钮用来打开应用;第二个按钮用来卸载这个应用 INFO按钮用来解析并显示出对应的LSApplicationProxy类 树形展示LSApplicationProxy类 通过算法,将LSApplicationProxy类,转换成了字典。 转换规则是:属性名为key,属性值为value,如果value是一个可解析的类(除了NSString,NSNumber...等等)或者是个数组或字典,则继续递归解析。 并且会找到superClass的属性并解析,superClass如...
基于遗传算法辅助异构改进的动态多群粒子群优化算法(GA-HIDMSPSO)的LSTM分类预测研究(Matlab代码实现)内容概要:本文研究了一种基于遗传算法辅助异构改进的动态多群粒子群优化算法(GA-HIDMSPSO),并将其应用于LSTM神经网络的分类预测中,通过Matlab代码实现。该方法结合遗传算法的全局搜索能力与改进的多群粒子群算法的局部优化特性,提升LSTM模型在分类任务中的性能表现,尤其适用于复杂非线性系统的预测问题。文中详细阐述了算法的设计思路、优化机制及在LSTM参数优化中的具体应用,并提供了可复现的Matlab代码,属于SCI级别研究成果的复现与拓展。; 适合人群:具备一定机器学习和优化算法基础,熟悉Matlab编程,从事智能算法、时间序列预测或分类模型研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①提升LSTM在分类任务中的准确性与收敛速度;②研究混合智能优化算法(如GA与PSO结合)在神经网络超参数优化中的应用;③实现高精度分类预测模型,适用于电力系统故障诊断、电池健康状态识别等领域; 阅读建议:建议读者结合Matlab代码逐步调试运行,理解GA-HIDMSPSO算法的实现细节,重点关注种群划分、异构策略设计及与LSTM的集成方式,同时可扩展至其他深度学习模型的参数优化任务中进行对比实验。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值