Java Jsoup(basic.class)CSS选择器不工作-html()显示元素存在,不太特定的选择器工作

Java Jsoup(basic.class)CSS选择器不工作-html()显示元素存在,不太特定的选择器工作,java,css,web-scraping,css-selectors,jsoup,Java,Css,Web Scraping,Css Selectors,Jsoup,对不起,这是一篇很长的帖子。如果向下滚动到底部编辑,问题可能会很清楚。 我正在分析的页面的一部分: <a href="/MangaList/MostPopular">Sort by popularity</a> <a href="/MangaList/Newest">New manga</a> <a class="bigChar" href="/Manga/Shinryaku-Ika-Musume">Shinryaku! Ika Mus

对不起,这是一篇很长的帖子。如果向下滚动到底部编辑,问题可能会很清楚。

我正在分析的页面的一部分:

<a href="/MangaList/MostPopular">Sort by popularity</a>
<a href="/MangaList/Newest">New manga</a>
<a class="bigChar" href="/Manga/Shinryaku-Ika-Musume">Shinryaku! Ika Musume</a>
<a href="/Genre/Comedy" class="dotUnder" title="A dramatic work that is light and often humorous or satirical in tone  and that usually contains a happy resolution of the thematic conflict.">Comedy</a>
上面是我正在运行的代码段

出于某种原因,doc.select(“.bigChar”)没有得到任何东西,因此doc.select(“.bigChar”)正在抛出一个NPE

您可以在上面的代码中看到我的调试输出行。以下是它的输出:

selecting from <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>
...<div> 
      <a class="bigChar" href="/Manga/Shinryaku-Ika-Musume">Shinryaku! Ika Musume</a> 
      <p> <span class="info">Genres:</span>&nbsp;<a href="/Genre/Comedy" class="dotUnder" title="A dramatic work that is light and often humorous or satirical in tone  and that usually 
....
 with a <a href="http://kissmanga.com/Login">Login</a>
<a href="http://kissmanga.com/Register"> Register</a>
...
<a class="bigChar" href="/Manga/Shinryaku-Ika-Musume">Shinryaku! Ika Musume</a>
...
  final 
输出:

[logo]
[bigChar]
found!
[dotUnder]
[dotUnder]
[dotUnder]
[dotUnder]
[dotUnder]
now: 

因此bigChar甚至被视为一个类,但是.bigChar选择器没有得到它…

你能用最小的静态html创建一个失败的例子吗,这样我们就可以重现它了?因为在我的测试中,一切正常我现在在我的手机上,所以我不能轻易地编辑它,但我打开了一个问题并在那里附上了一个示例文件(blahblah.txt)
    Elements as = doc.select("a");
    for (Element e : as) {
        if (e.classNames().size() > 0)
            M.debug(e.classNames());
        if(e.classNames().contains("bigChar")) {
            M.debug("found!");
        }
    }
    as = doc.select(".bigChar");
    M.debug("now: " + as);
    for (Element e : as) {
        if (e.classNames().size() > 0)
            M.debug(e.classNames());
    }
[logo]
[bigChar]
found!
[dotUnder]
[dotUnder]
[dotUnder]
[dotUnder]
[dotUnder]
now: