-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHtmlAnalyzer.java
More file actions
28 lines (23 loc) · 1002 Bytes
/
HtmlAnalyzer.java
File metadata and controls
28 lines (23 loc) · 1002 Bytes
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
public class HtmlAnalyzer {
/**
* This method receives a URL link by args and analyzed the HTML structure loaded from it, printing:
* 1. The string that is the deepest level text found in the HTML structure; OR
* 2. The "URL connection error" message, if occurred an error while trying to connect to the URL; OR
* 3. The "malformed HTML" message, if the HTML structure loaded is malformed.
* @param args String that contains a URL for html code to be analyzed
*/
public static void main(String[] args){
Loader loader = new Loader();
Extractor extractor = new Extractor();
String deepestPart = null;
String content;
String urlInput = args[0];
try {
content = loader.getContent(urlInput);
deepestPart = extractor.findDeepest(content);
System.out.println(deepestPart);
} catch (Exception ex) {
System.out.println("URL connection error");
}
}
}