Giter Club home page Giter Club logo

Comments (3)

code4craft avatar code4craft commented on August 17, 2024

得知Jsoup也有XPath解析功能,见讨论http://www.oschina.net/question/234880_121668,考虑将XPath实现由HtmlCleaner转为Jsoup。
感谢@searchjack发现问题。

from webmagic.

code4craft avatar code4craft commented on August 17, 2024

沟通失误,Jsoup应该是没有XPath功能的。不过CSS Selector在class属性有多个值,并且用空格分隔的时候,可以用单个属性选择,而XPath则必须包括全部。
按照我的理解是这样的:

  • 对于html的class属性,空格表示两个属性并列,Jsoup使用的CSS Selector,当然知道这是两个属性,所以选择其中一个也有效。
  • 但是XPath是针对XML的,并不知道这个语法,就把连同空格的两个属性值一起放进去作为了一个属性值,所以无法分开。

这样看来CSS Selector有时候还是更方便一点的。

from webmagic.

code4craft avatar code4craft commented on August 17, 2024

在0.3.0之后,改用了Xsoup。现在class可以选择单个属性,并且有更加详细的错误提示了。

from webmagic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.