-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetURL.java
More file actions
74 lines (52 loc) · 2.37 KB
/
Copy pathgetURL.java
File metadata and controls
74 lines (52 loc) · 2.37 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.LinkedHashMap;
import java.util.Map;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
class getURL {
public static Map<String, String> pdfLinkGenerator2231(String meetingNum) {
Map<String, String> pdfLinks = new LinkedHashMap<>();
try {
// Get String of the meeting number and combine it with a default URL
String url = "http://web.cse.ohio-state.edu/software/2231/web-sw2/generated/s" + meetingNum + ".html";
// Connect the jsoup with this url and get this html as a document
Document doc = Jsoup.connect(url).get();
// Get the links from the html
Elements links = doc.getElementsByTag("a");
// Iterate and store all the pdf links to the map
for (Element link : links) {
String linkHref = "http://web.cse.ohio-state.edu/software/2231/web-sw2/";
linkHref += link.attr("href").substring(3);
String linkText = link.text();
pdfLinks.put(linkText, linkHref);
}
} catch (Exception e) {
}
// Return the titles and links of pdfs in this html
return pdfLinks;
}
public static Map<String, String> pdfLinkGenerator2221(String meetingNum) {
Map<String, String> pdfLinks = new LinkedHashMap<>();
try {
// Get String of the meeting number and combine it with a default URL
String url = "http://web.cse.ohio-state.edu/software/2221/web-sw1/generated/s" + meetingNum + ".html";
// Connect the jsoup with this url and get this html as a document
Document doc = Jsoup.connect(url).get();
// Get the links from the html
Elements links = doc.getElementsByTag("a");
// Iterate and store all the pdf links to the map
for (Element link : links) {
String linkHref = "http://web.cse.ohio-state.edu/software/2221/web-sw1/";
linkHref += link.attr("href").substring(3);
String linkText = link.text();
pdfLinks.put(linkText, linkHref);
}
} catch (Exception e) {
}
// Return the titles and links of pdfs in this html
return pdfLinks;
}
public static void main(String[] args) {
}
}