Follow these steps:
- Add the following imports to the project:
import java.io.File;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
- Add the following try block to the main method:
try {
String htmlText = Jsoup.connect("https://en.wikipedia.org/wiki/Language").get().html();
System.out.println(htmlText.substring(0, 100));
System.out.println();
} catch (IOException e) {
// Handle exceptions
}
- Execute the program. You will get the following output:
<!doctype html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8">