`
李丹.杭州
  • 浏览: 15521 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

Htmlparser Filter 简要归纳(转)

阅读更多
1 . 逻辑关系:与或非
AndFilter()
          Creates a new instance of an AndFilter.
AndFilter(NodeFilter[] predicates)
          Creates an AndFilter that accepts nodes acceptable to all given filters.
AndFilter(NodeFilter left, NodeFilter right)
          Creates an AndFilter that accepts nodes acceptable to both filters.






OrFilter()
          Creates a new instance of an OrFilter.
OrFilter(NodeFilter[] predicates)
          Creates an OrFilter that accepts nodes acceptable to any of the given filters.
OrFilter(NodeFilter left, NodeFilter right)
          Creates an OrFilter that accepts nodes acceptable to either filter.






OrFilter()
          Creates a new instance of an OrFilter.
OrFilter(NodeFilter[] predicates)
          Creates an OrFilter that accepts nodes acceptable to any of the given filters.
OrFilter(NodeFilter left, NodeFilter right)
          Creates an OrFilter that accepts nodes acceptable to either filter.



2. 内容

StringFilter:功能简单有限;复杂功能可使用RegexFilter (正则表达式)


StringFilter()
          Creates a new instance of StringFilter that accepts all string nodes.
StringFilter(String pattern)
          Creates a StringFilter that accepts text nodes containing a string.
StringFilter(String pattern, boolean sensitive)
          Creates a StringFilter that accepts text nodes containing a string.
StringFilter(String pattern, boolean sensitive, Locale locale)
          Creates a StringFilter that accepts text nodes containing a string.




RegexFilter()
          Creates a new instance of RegexFilter that accepts string nodes matching the regular expression ".*" using the FIND strategy.
RegexFilter(String pattern)
          Creates a new instance of RegexFilter that accepts string nodes matching a regular expression using the FIND strategy.
RegexFilter(String pattern, int strategy)
          Creates a new instance of RegexFilter that accepts string nodes matching a regular expression.





3 标签

TagNameFilter()利用标签名过滤 : div ,img , ...

NodeClassFilter()利用标签类别 :LinkTag.class ...

HasAttributeFilter()利用属性 :HasAttributeFilter(“class”, “className”)

LinkRegexFilter()用正则表达式匹配链接


TagNameFilter()
          Creates a new instance of TagNameFilter.
TagNameFilter(String name)
          Creates a TagNameFilter that accepts tags with the given name.




NodeClassFilter()
          Creates a NodeClassFilter that accepts Html tags.
NodeClassFilter(Class cls)
          Creates a NodeClassFilter that accepts tags of the given class.
HasAttributeFilter()
          Creates a new instance of HasAttributeFilter.
HasAttributeFilter(String attribute)
          Creates a new instance of HasAttributeFilter that accepts tags with the given attribute.
HasAttributeFilter(String attribute, String value)
          Creates a new instance of HasAttributeFilter that accepts tags with the given attribute and value.
LinkRegexFilter(String regexPattern)
          Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern.
LinkRegexFilter(String regexPattern, boolean caseSensitive)
          Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern.
LinkStringFilter(String pattern)
          Creates a LinkStringFilter that accepts LinkTag nodes containing a URL that matches the supplied pattern.
LinkStringFilter(String pattern, boolean caseSensitive)
          Creates a LinkStringFilter that accepts LinkTag nodes containing a URL that matches the supplied pattern.





4 层次关系


HasParentFilter()
          Creates a new instance of HasParentFilter.
HasParentFilter(NodeFilter filter)
          Creates a new instance of HasParentFilter that accepts nodes with the direct parent acceptable to the filter.
HasParentFilter(NodeFilter filter, boolean recursive)
          Creates a new instance of HasParentFilter that accepts nodes with a parent acceptable to the filter.




HasChildFilter()
          Creates a new instance of a HasChildFilter.
HasChildFilter(NodeFilter filter)
          Creates a new instance of HasChildFilter that accepts nodes with a direct child acceptable to the filter.
HasChildFilter(NodeFilter filter, boolean recursive)
          Creates a new instance of HasChildFilter that accepts nodes with a child acceptable to the filter.

分享到:
评论

相关推荐

    HtmlParser用于将HTML转换为PugJinja2和Blade模板的交互式工具

    HTMLParser是一款强大的交互式工具,专门设计用于将HTML代码转换为Pug、Jinja2和Blade这三种流行的模板引擎格式。这个工具对于开发者来说,尤其是那些习惯于使用静态HTML,但希望转向更强大、更简洁的模板语言的...

    htmlparser

    org.htmlparser.beans.FilterBean.class org.htmlparser.beans.HTMLLinkBean.class org.htmlparser.beans.HTMLTextBean.class org.htmlparser.beans.LinkBean.class org.htmlparser.beans.StringBean.class org....

    HtmlParser

    使用HTMLParser,我们可以解析网页内容,提取所需信息,如文章标题、链接、图片等。以下是一些核心概念和步骤: 1. **创建自定义解析器**: 首先,我们需要继承Python的`HTMLParser`类,并重写其方法,如`handle_...

    htmlparser(HTML页面解析)例子

    首先,我们需要导入Python的`HTMLParser`模块。在Python 3中,这个模块已经被重命名为`html.parser`,因此应该导入`html.parser`,而不是`HTMLParser`。以下是如何导入的示例: ```python from ...

    htmlparser.jar文件

    在描述中提到的“org.htmlparser.Node”和其他的.class文件,这些都是HTMLParser库的核心组成部分。`org.htmlparser.Node` 是HTMLParser中的一个关键接口,它代表HTML文档中的一个节点,可以是元素(Element)、注释...

    HTMLParser.net源代码HTMLParser.net使用demo

    本项目名为"HTMLParser.net源代码HTMLParser.net使用demo",显然是一个包含示例代码的压缩包,用于展示如何在实际应用中使用HTMLParser.net。 HTMLParser.net的核心功能包括: 1. **HTML解析**:它能够将HTML字符...

    htmlparser-1.2.1 jar

    htmlparser-1.2.1jar包下载htmlparser-1.2.1jar包下载

    htmlparser网页分析

    以下是对HTMLParser及其相关知识点的详细说明: 1. HTML解析:HTMLParser的设计目的是为了处理HTML文档的非结构化特性。由于HTML经常存在不规范的情况,如缺少闭合标签、嵌套错误等,HTMLParser通过容错机制,能够...

    htmlparser库与教程

    在“htmlparser.jar”中,包含了HTMLParser库的所有类和方法,使得开发人员可以将这个库集成到他们的Java项目中。使用jar文件,开发者可以直接导入并使用HTMLParser的API来解析和操作HTML文档。 "htmlparser实现从...

    HtmlParser源码及demo

    以下是对`HtmlParser`及其相关知识点的详细说明: 1. **HTML解析**:HTMLParser提供了对HTML文档的解析能力,将HTML文本转换为可操作的对象模型。它能够处理嵌套标签、属性、注释以及实体引用等HTML元素。 2. **...

    HTMLParser的Jar文件

    HTMLParser的Jar文件有如下几种: htmlparser.jar filterbuilder.jar htmllexer.jar sitecapturer.jar thumbelina.jar

    c#版htmlparser htmlparser.dll htmlparser源代码

    `htmlparser.dll`是这个库的动态链接库文件,它包含了编译好的类和方法,可以直接在C#项目中引用以使用HTMLParser的功能。在C#项目中,我们可以通过添加对dll的引用来调用库中的方法,比如解析HTML字符串、查找特定...

    Winista.Htmlparser.Net 源码 +Demo

    `HtmlParser2003`可能是一个早期版本的源代码,而`AnalyzeHtml`和`WebParser`则可能是演示如何使用HtmlParser的项目。 1. **AnalyzeHtml**:这个项目可能展示了如何分析HTML文档,通过调用HtmlParser的API来提取...

    htmlParser.jar包

    在很多Web抓取、信息提取以及网页分析的项目中,HTMLParser都是一个理想的工具。 HTMLParser库的设计考虑了易用性和灵活性,它提供了丰富的API,允许开发者通过编程方式来访问和操作HTML文档的各个元素,如标签、...

    htmlparser2.0_dll+htmlparserAPI

    `filterbuilder.dll`可能是用于构建和管理过滤器的组件。过滤器在HTML解析中起着重要作用,它们允许开发者根据特定规则筛选或修改HTML内容。例如,你可以创建一个过滤器来删除所有广告元素,或者将某些URL替换为短...

    HtmlParser 实现简易爬虫

    在本场景中,我们讨论如何使用HTMLParser库来创建一个基础的网络爬虫,以便从网页上抓取和分析数据。 首先,我们需要了解HTMLParser的基本用法。HTMLParser设计为易于使用,它提供了对HTML元素、属性和文本的访问,...

    HTMLParser 使用举例

    HTMLParser 使用举例 HTMLParser 是一个开源的类库,用于解析 Web 页面。它有两种主要使用方式:extraction 和 transformation。前者用于从网页中萃取出需要的内容,后者用于把 Web 页面中的内容转换为需要的格式。...

    JAVA htmlparser 使用实例

    org.htmlparser.util.NodeList nodes = parser.extractAllNodesThatMatch(filter); // 获取所有匹配的标签中的第一个 org.htmlparser.tags.TableTag textnode = (org.htmlparser.tags.TableTag) ((org.htmlparser...

Global site tag (gtag.js) - Google Analytics