File tree 2 files changed +39
-26
lines changed
Chapter09/src/main/java/com/packtpub/http
2 files changed +39
-26
lines changed Original file line number Diff line number Diff line change
1
+ package com .packtpub .http ;
2
+
3
+ import org .jsoup .Jsoup ;
4
+ import org .jsoup .nodes .Document ;
5
+ import org .jsoup .nodes .Element ;
6
+ import org .jsoup .select .Elements ;
7
+
8
+ import java .io .IOException ;
9
+
10
+ public class Activity1 {
11
+
12
+ public static void main (String [] args ) {
13
+
14
+ try {
15
+ String url = "http://hc.apache.org/" ;
16
+
17
+ Document doc =
18
+ Jsoup .connect (url ).get ();
19
+
20
+ Elements sections = doc .select ("div.section" );
21
+
22
+ for (Element div : sections ) {
23
+
24
+ for (Element child : div .children ()) {
25
+ String tag = child .tagName ();
26
+ if (tag .equalsIgnoreCase ("h3" )) {
27
+
28
+ Elements links = child .getElementsByTag ("a" );
29
+ for (Element link : links ) {
30
+ System .out .println (link .text ());
31
+ }
32
+ }
33
+ }
34
+ }
35
+ } catch (IOException e ) {
36
+ e .printStackTrace ();
37
+ }
38
+ }
39
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments