Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 45835db

Browse filesBrowse files
committed
Jsoup example
1 parent 9305730 commit 45835db
Copy full SHA for 45835db

File tree

Expand file treeCollapse file tree

10 files changed

+370
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

10 files changed

+370
-0
lines changed
Open diff view settings
Collapse file

‎com.vogella.jsoup.links/.classpath‎

Copy file name to clipboard
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/java">
4+
<attributes>
5+
<attribute name="FROM_GRADLE_MODEL" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
9+
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
10+
<classpathentry kind="output" path="bin"/>
11+
</classpath>
Collapse file

‎com.vogella.jsoup.links/.project‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>com.vogella.jsoup.links</name>
4+
<comment>Project com.vogella.jsoup.links created by Buildship.</comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>
Collapse file
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
build.commands=org.eclipse.jdt.core.javabuilder
2+
connection.arguments=
3+
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
4+
connection.gradle.user.home=null
5+
connection.java.home=null
6+
connection.jvm.arguments=
7+
connection.project.dir=
8+
derived.resources=.gradle,build
9+
eclipse.preferences.version=1
10+
natures=org.eclipse.jdt.core.javanature
11+
project.path=\:
Collapse file
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apply plugin: 'java'
2+
3+
repositories {
4+
jcenter()
5+
}
6+
7+
// In this section you declare the dependencies for your production and test code
8+
dependencies {
9+
compile 'org.jsoup:jsoup:1.9.1'
10+
}
Collapse file
52.1 KB
Binary file not shown.
Collapse file
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Wed May 11 14:11:53 CEST 2016
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-2.14-20160501000014+0000-bin.zip
Collapse file

‎com.vogella.jsoup.links/gradlew‎

Copy file name to clipboardExpand all lines: com.vogella.jsoup.links/gradlew
+164Lines changed: 164 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎com.vogella.jsoup.links/gradlew.bat‎

Copy file name to clipboardExpand all lines: com.vogella.jsoup.links/gradlew.bat
+90Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This settings file was auto generated by the Gradle buildInit task
3+
* by 'vogella' at '5/11/16 2:11 PM' with Gradle 2.14-20160501000014+0000
4+
*
5+
* The settings file is used to specify which projects to include in your build.
6+
* In a single project build this file can be empty or even removed.
7+
*
8+
* Detailed information about configuring a multi-project build in Gradle can be found
9+
* in the user guide at https://docs.gradle.org/2.14-20160501000014+0000/userguide/multi_project_builds.html
10+
*/
11+
12+
/*
13+
// To declare projects as part of a multi-project build use the 'include' method
14+
include 'shared'
15+
include 'api'
16+
include 'services:webservice'
17+
*/
18+
19+
rootProject.name = 'com.vogella.jsoup.links'
Collapse file
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.io.IOException;
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+
public class ParseLinksExample {
9+
10+
public static void main(String[] args) {
11+
12+
Document doc;
13+
try {
14+
15+
doc = Jsoup.connect("http://www.vogella.com").get();
16+
17+
// get title of the page
18+
String title = doc.title();
19+
System.out.println("Title: " + title);
20+
21+
// get all links
22+
Elements links = doc.select("a[href]");
23+
for (Element link : links) {
24+
25+
// get the value from href attribute
26+
System.out.println("\nLink : " + link.attr("href"));
27+
System.out.println("Text : " + link.text());
28+
}
29+
30+
} catch (IOException e) {
31+
e.printStackTrace();
32+
}
33+
34+
}
35+
36+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.