Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,28 @@ public static String theloai(String url) throws IOException {
return returnString;
}

public static String contentInfoBox( String element) throws IOException {
String returnString = "";
Document doc = Jsoup.connect("https://vi.wikipedia.org/wiki/Chi%E1%BA%BFn_tranh_H%C3%A1n%E2%80%93Vi%E1%BB%87t_(42%E2%80%9343)").get();
Element content = doc.getElementsByClass("infobox vevent").first();
Element contentSpecial = content.getElementsMatchingOwnText(element).first();

if (contentSpecial != null && contentSpecial.nextElementSibling() != null) {
returnString = returnString + contentSpecial.nextElementSibling().text();
}
return returnString;
}

public static void mota(String url) throws IOException{
Document doc = Jsoup.connect(url).get();
Element div = doc.select("div.mw-parser-output").first();
Element des = div.select("p").first();
System.out.println(des.text());
}
public static void main(String[] args) throws IOException {
System.out
.println(theloai("https://vi.wikipedia.org/wiki/Chi%E1%BA%BFn_tranh_T%E1%BA%A7n%E2%80%93Vi%E1%BB%87t"));
// System.out
// .println(theloai("https://vi.wikipedia.org/wiki/Chi%E1%BA%BFn_tranh_T%E1%BA%A7n%E2%80%93Vi%E1%BB%87t"));
//System.out.println(contentInfoBox("Thời gian"));
mota("https://vi.wikipedia.org/wiki/Chi%E1%BA%BFn_tranh_T%E1%BA%A7n%E2%80%93Vi%E1%BB%87t");
}
}
20 changes: 6 additions & 14 deletions Main/ExtractData.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,12 @@ public void writeData(String url) throws IOException {
}
}

for (Map<String, String> d : data) {
JSONObject jsonObject1 = new JSONObject(d);
jsonArray.add(jsonObject1);
}

try (
FileWriter fileWriter = new FileWriter("E:/OOP/javaProject/Main/extractData.json")) {
String modifiedJsonString = unescapeUnicode(jsonArray.toString());
fileWriter.write(modifiedJsonString);
fileWriter.flush();
} catch (IOException e) {
e.printStackTrace();
}

// to store data
String databaseFile = "E:/OOP/javaProject/Main/extractData.json"; // the json file, where data is stored
JsonDatabase database = new JsonDatabase(databaseFile); // create a json database, you need to import this class
database.store(data); // store list of map<String, String> into database
database.close(); // save changes to json file

}

}