-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlAnalyzer.java
More file actions
39 lines (33 loc) · 1.19 KB
/
HtmlAnalyzer.java
File metadata and controls
39 lines (33 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.List;
/**
* The HtmlAnalyzer class is the main entry point for analyzing HTML content.
* It fetches HTML lines from a given URL, parses the HTML to extract the deepest text,
* and prints the result to the console.
*/
public class HtmlAnalyzer {
/**
* The main method that serves as the entry point of the application.
* It expects a single argument which is the URL to fetch HTML content from.
*
* @param args the command line arguments, where args[0] should be the URL
*/
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java HtmlAnalyzer <url>");
return;
}
HtmlFetcher fetcher = new HtmlFetcher();
List<String> htmlLines = fetcher.fetchHtmlLines(args[0]);
if (htmlLines == null) {
System.out.println("Url connection error");
return;
}
HtmlParser parser = new HtmlParser();
try {
String deepestText = parser.getDeepestText(htmlLines);
System.out.println(deepestText);
} catch (MalformedHtmlException e) {
System.out.println(e.getMessage());
}
}
}