Java Jsoup获取类的文本

时间:2016-07-16 16:12:44

标签: java jsoup

当我尝试时,

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;

public class main {

     public static void main(String[] args) throws IOException {
         Document doc = (Document) Jsoup.connect("https://steamcommunity.com/id/n096846").get();
         Elements test = doc.getElementsByClass("error_ctn");
         System.out.println(test.text());
    }
}

打印出来

Error Sorry! An error was encountered while processing your request: The specified profile could not be found. Here's a link to the Steam Community home page.

然后,当我尝试

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;

public class main {

     public static void main(String[] args) throws IOException {
         Document doc = (Document) Jsoup.connect("http://www.lolking.net/leaderboards#/na/1").get();
         Elements test = doc.getElementsByClass("leaderboard-summoner-name");
         System.out.println(test.text());
    }
}

它什么都没打印出来。有原因吗?是否有可能打印出来的东西?

0 个答案:

没有答案