Skip to content

Commit 59b9c5a

Browse files
tzaeschkeTilmann Zäschke
andauthored
ISD-AS assignment (#13)
* ISD-AS assignment --------- Co-authored-by: Tilmann Zäschke <[email protected]>
1 parent b81a14d commit 59b9c5a

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## [Unreleased]
99

10-
- Nothing yet
10+
### Fixed
11+
12+
- ISD-AS assignment parser broken after website change
13+
[#12](https://github.com/netsec-ethz/scion-java-multiping/pull/12)
1114

1215
## [0.4.0] - 2025-04-04
1316

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>org.scion</groupId>
8585
<artifactId>jpan</artifactId>
86-
<version>0.5.1</version>
86+
<version>0.5.3</version>
8787
</dependency>
8888

8989
<dependency>

src/main/java/org/scion/multiping/util/DownloadAssignmentsFromWeb.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
import java.io.IOException;
1818
import java.util.ArrayList;
1919
import java.util.List;
20+
2021
import org.jsoup.Jsoup;
2122
import org.jsoup.nodes.Document;
2223
import org.jsoup.nodes.Element;
2324
import org.scion.jpan.ScionUtil;
2425

2526
public class DownloadAssignmentsFromWeb {
2627
private static final String HTTPS_URL =
27-
"https://docs.anapaya.net/en/latest/resources/isd-as-assignments/";
28+
"https://docs.anapaya.net/en/latest/resources/isd-as-assignments/";
2829

2930
public static void main(String[] args) throws IOException {
3031
new DownloadAssignmentsFromWeb().jsoup();
@@ -42,22 +43,26 @@ public static List<ParseAssignments.HostEntry> getList() {
4243
public List<ParseAssignments.HostEntry> jsoup() throws IOException {
4344
List<ParseAssignments.HostEntry> result = new ArrayList<>(100);
4445
Document doc = Jsoup.connect(HTTPS_URL).get();
45-
for (Element bc : doc.body().getElementsByAttributeValue("id", "isd-membership")) {
46-
// System.out.println("eee " + bc);
47-
for (Element bc2 : bc.getElementsByTag("tbody")) {
48-
// System.out.println("eee2 " + bc2);
49-
for (Element bc3 : bc2.children()) {
50-
// System.out.println("eee3 " + bc3);
51-
String isdAs = bc3.child(0).getElementsByTag("p").text();
52-
String name = bc3.child(1).getElementsByTag("p").text();
53-
// System.out.println(isdAs + " " + name);
54-
result.add(new ParseAssignments.HostEntry(ScionUtil.parseIA(isdAs), name));
55-
// for (Element bc4 : bc3.children()) {
56-
// System.out.println("eee4 " + bc4.getElementsByTag("p").text());
57-
// }
46+
47+
for (Element table : doc.getElementsByTag("table")) {
48+
for (Element isd_as : table.getElementsContainingText("ISD-AS")) {
49+
if ("table".equals(isd_as.tagName())) {
50+
for (Element te : table.children()) {
51+
if ("thead".equals(te.tagName())) {
52+
continue;
53+
}
54+
for (Element te2 : te.children()) {
55+
// System.out.println(" te3: " + te2.tag());
56+
String isdAs = te2.child(0).getElementsByTag("td").text();
57+
String name = te2.child(1).getElementsByTag("td").text();
58+
// System.out.println(isdAs + " " + name);
59+
result.add(new ParseAssignments.HostEntry(ScionUtil.parseIA(isdAs), name));
60+
}
61+
}
5862
}
5963
}
6064
}
65+
6166
return result;
6267
}
6368
}

0 commit comments

Comments
 (0)