我正在尋找一些網絡爬行/抓取,我做了一些研究,發現了Jsoup。我遇到的唯一問題是進口。我看過的視頻和我見過的例子都有匹配的代碼,但無論出於何種原因,它們的導入工作都是有效的,而我的例子則不然。我的所有四個都給出錯誤:導入org.jsoup無法解析。請幫忙。Jsoup導入錯誤
package com.stackoverflow.q2835505;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class test {
public static void main(String[] args) throws Exception {
String url = "http://stackoverflow.com/questions/2835505";
Document document = Jsoup.connect(url).get();
String question = document.select("#question .post-text").text();
System.out.println("Question: " + question);
Elements answerers = document.select("#answers .user-details a");
for (Element answerer : answerers) {
System.out.println("Answerer: " + answerer.text());
}
}
}
你下載了正確的jar並添加到項目classpath/buildpath中嗎? – Pshemo