nutch如何修改regex-urlfilter.txt爬取符合条件的链接
例如我在爬取学生在线的时候,发现爬取不到特定的通知,例如《中粮福临门助学基金申请公告》,通过分析发现原来通知的链接被过滤掉了,下面对过滤url的配置文件regex-urlfilter.txt进行分析,以后如果需要修改可以根据自己的情况对该配置文件进行修改:
说明:配置文件中以“#”开头的行为注释,以“-" 开头的表示符合正则表达式就过滤掉,以“+”开头的表示符合正则表达式则保留。正则表达式中"^"表示字符串的开头,"$"表示字符串的结尾,"[]"表示集合。中文部分是我添加的注释
- # Licensed to the Apache Software Foundation (ASF) under one or more
- # contributor license agreements. See the NOTICE file distributed with
- # this work for additional information regarding copyright ownership.
- # The ASF licenses this file to You under the Apache License, Version 2.0
- # (the "License"); you may not use this file except in compliance with
- # the License. You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # The default url filter.
- # Better for whole-internet crawling.
- # Each non-comment, non-blank line contains a regular expression
- # prefixed by '+' or '-'. The first matching pattern in the file
- # determines whether a URL is included or ignored. If no pattern
- # matches, the URL is ignored.
- # skip file: ftp: and mailto: urls
- #过滤掉file:ftp等不是html协议的链接
- -^(file|ftp|mailto):
- # skip image and other suffixes we can't yet parse
- #过滤掉图片等格式的链接
- -\.(gif|GIF|jpg|JPG|png|PNG|ico|ICO|css|sit|eps|wmf|zip|ppt|mpg|xls|gz|rpm|tgz|mov|MOV|exe|jpeg|JPEG|bmp|BMP)$
- # skip URLs containing certain characters as probable queries, etc.
- #-[?*!@=] 过滤掉汗特殊字符的链接,因为要爬取更多的链接,所以修改过滤条件,使包含?=的链接不被过滤掉
- -[*!@]
- # skip URLs with slash-delimited segment that repeats 3+ times, to break loops
- #过滤掉一些特殊格式的链接
- -.*(/[^/]+)/[^/]+\1/[^/]+\1/
- # accept anything else
- #接受所有的链接,这里可以做自己的修改,是的只接受自己规定类型的链接
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.The default url filter.
Better for whole-internet crawling.
Each non-comment, non-blank line contains a regular expression
prefixed by '+' or '-'. The first matching pattern in the file
determines whether a URL is included or ignored. If no pattern
matches, the URL is ignored.
skip file: ftp: and mailto: urls
过滤掉file:ftp等不是html协议的链接
-^(file|ftp|mailto):skip image and other suffixes we can't yet parse
过滤掉图片等格式的链接
-.(gif|GIF|jpg|JPG|png|PNG|ico|ICO|css|sit|eps|wmf|zip|ppt|mpg|xls|gz|rpm|tgz|mov|MOV|exe|jpeg|JPEG|bmp|BMP)$skip URLs containing certain characters as probable queries, etc.
-[?*!@=] 过滤掉汗特殊字符的链接,因为要爬取更多的链接,所以修改过滤条件,使包含?=的链接不被过滤掉
-[*!@]skip URLs with slash-delimited segment that repeats 3+ times, to break loops
过滤掉一些特殊格式的链接
-.*(/[/]+)/[/]+\1/[^/]+\1/accept anything else
接受所有的链接,这里可以做自己的修改,是的只接受自己规定类型的链接
原因解释:因为爬取的公告链接为(http://www.online.sdu.edu.cn/news/article.php?pid=636514943),链接中含有?和=字符,所以被过滤特殊字符的正则表达式过滤掉,通过修改regex-urlfilter.txt配置文件(如上),最终可以爬取这类公告的链接。
nutch如何修改regex-urlfilter.txt爬取符合条件的链接的更多相关文章
- Java爬虫爬取网站电影下载链接
之前有看过一段时间爬虫,了解了爬虫的原理,以及一些实现的方法,本项目完成于半年前,一直放在那里,现在和大家分享出来. 网络爬虫简单的原理就是把程序想象成为一个小虫子,一旦进去了一个大门,这个小虫子就像 ...
- 从0开始学爬虫8使用requests/pymysql和beautifulsoup4爬取维基百科词条链接并存入数据库
从0开始学爬虫8使用requests和beautifulsoup4爬取维基百科词条链接并存入数据库 Python使用requests和beautifulsoup4爬取维基百科词条链接并存入数据库 参考 ...
- Java分布式爬虫Nutch教程——导入Nutch工程,执行完整爬取
Java分布式爬虫Nutch教程--导入Nutch工程,执行完整爬取 by briefcopy · Published 2016年4月25日 · Updated 2016年12月11日 在使用本教程之 ...
- 【Python3 爬虫】06_robots.txt查看网站爬取限制情况
大多数网站都会定义robots.txt文件来限制爬虫爬去信息,我们在爬去网站之前可以使用robots.txt来查看的相关限制信息 例如: 我们以[CSDN博客]的限制信息为例子 在浏览器输入:http ...
- python爬虫——爬取小说 | 探索白子画和花千骨的爱恨情仇(转载)
转载出处:药少敏 ,感谢原作者清晰的讲解思路! 下述代码是我通过自己互联网搜索和拜读完此篇文章之后写出的具有同样效果的爬虫代码: from bs4 import BeautifulSoup imp ...
- scrapy实例:爬取中国天气网
1.创建项目 在你存放项目的目录下,按shift+鼠标右键打开命令行,输入命令创建项目: PS F:\ScrapyProject> scrapy startproject weather # w ...
- python学习(23)requests库爬取猫眼电影排行信息
本文介绍如何结合前面讲解的基本知识,采用requests,正则表达式,cookies结合起来,做一次实战,抓取猫眼电影排名信息. 用requests写一个基本的爬虫 排行信息大致如下图 网址链接为ht ...
- Python 爬取 热词并进行分类数据分析-[热词分类+目录生成]
日期:2020.02.04 博客期:143 星期二 [本博客的代码如若要使用,请在下方评论区留言,之后再用(就是跟我说一声)] 所有相关跳转: a.[简单准备] b.[云图制作+数据导入] c.[ ...
- python入门学习之Python爬取最新笔趣阁小说
Python爬取新笔趣阁小说,并保存到TXT文件中 我写的这篇文章,是利用Python爬取小说编写的程序,这是我学习Python爬虫当中自己独立写的第一个程序,中途也遇到了一些困难,但是最后 ...
随机推荐
- HDU 1475 Pushing Boxes
Pushing Boxes Time Limit: 2000ms Memory Limit: 131072KB This problem will be judged on PKU. Original ...
- HDU5514 Frogs
/* HDU5514 Frogs http://acm.hdu.edu.cn/showproblem.php?pid=5514 容斥原理 * * */ #include <cstdio> ...
- [SharePoint2010开发入门经典]12、SPS2010安全管理
本章概要: 1.SPS中的用户授权 2.理解服务器场解决方案和沙箱解决方案的不同 3.理解表单验证和声明验证
- HDU 4340
好题一道啦.做这题时,抓住两个问题:一.给某点染色时,其连通的点是否已有一点以全部代价染色.二.该点染什么颜色. 嗯.第二个问题很容易,但第一个问题不容易了.我一开始就考虑祖父子三层结点的关系,认为在 ...
- mongodb后台执行
默认的情况下,关闭shell,mongodb就停止执行了. 假设想在后台执行,启动时仅仅需加入 --fork函数就可以. 能够在日志路径后面加入--logappend.防止日志被删除. bin/mon ...
- BZOJ4031——HEOI小z的房间
题意:求某网格图生成树个数,对1e9取模 题解:题目是裸的Matrix-Tree定理,这不是我要说的重点,重点是对于这个取模的处理. 由于这不是个质数,所以不能直接乘逆元来当除法用.直接高斯消元肯定是 ...
- 全面具体介绍一个P2P网贷领域的ERP系统的主要功能
一般的P2P系统,至少包含PC站点的前端和后端.前端系统的功能.能够參考"P2P系统哪家强,功能事实上都一样" http://blog.csdn.net/fansunion ...
- XTU1202:逆序数
题目描写叙述 有n张卡片,分别标有数字1~n. 有一天Silence把他们按某种序列排好.然后从第一张開始取出一张,再拿一张放到最后面.再取出一张,再拿出一张放到最后面...知道n张卡片所有取走. 把 ...
- 入门 IT 行业,该具备哪些技能?
对于刚开始进入IT的新人来说,“必备技能”往往意味着一个长长的.标有重要度的学习列表,但是过长的列表通常会导致新人不知如何开始学习,压力倍增.本文尝试列举出最重要的几个技能,也期望通过此列表能给新人一 ...
- c++ sort函数的用法
C++ sort函数用法 FROM:http://hi.baidu.com/blackdemonfish/blog/item/e2c1d655d702a45ed0090652%2Ehtml 最近算法作 ...