0
我已經搜索了比任何東西都更正確的解決方案,但我仍無法修復。 請看這&幫助我。如何從多個網址獲取文章內容
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class NewClass {
public static void main(String[] args) throws IOException {
Document doc = Jsoup.connect("http://tamilblog.ishafoundation.org").get();
Elements section = doc.select("section#content");
Elements article = section.select("article");
for (Element a : article) {
System.out.println("Title : \n" + a.select("a").text());
System.out.println("Article summary: \n" + a.select("div.entry-summary").text());
}
}
}
我有上面的代碼從一個頁面獲取文章及其內容。
Document doc = Jsoup.connect("http://tamilblog.ishafoundation.org").get();
我想爲幾個網站做這個。
在這一行或使用一些迭代,我想申請我的代碼爲幾個網頁說500+。 我想將它保存在文章標題及其內容下的單獨文本文檔中。
我是新來編碼,所以我找不到正確的代碼。
我在做這個代碼過去兩個月來創建我的代碼。