Libraryless. Click here for Pure Java version (1643L/12K/37K).
1 | !752 |
2 | |
3 | m {
|
4 | static bool real = false; |
5 | static S html; |
6 | |
7 | static class Headline {
|
8 | S title, link, date, time; |
9 | } |
10 | |
11 | static new L<Headline> headlines; |
12 | |
13 | p {
|
14 | html = real ? loadPage("http://tinybrain.blog.de") : loadSnippet("#3000133");
|
15 | |
16 | // puts all tags on even indices, all text on odd indices |
17 | L<S> tok = htmlcoarsetok(html); |
18 | |
19 | //print(fromLines(tok)); |
20 | |
21 | S link = null; |
22 | Headline hl = null; |
23 | for (int i = 1; i < l(tok); i += 2) {
|
24 | S t = tok.get(i); |
25 | if (tagIs(t, "a")) |
26 | link = "http://tinybrain.blog.de" + tagGet(t, "href"); |
27 | if (eqic(t, "<span class=\"name\">")) {
|
28 | headlines.add(hl = new Headline); |
29 | hl.link = link; |
30 | hl.title = htmldecode(tok.get(i+1)); |
31 | print("Headline: " + hl.title);
|
32 | print(" Link: " + link);
|
33 | } |
34 | |
35 | if (eqic(t, "<span class=\"date\">") && hl != null && match("*-*-*", tok.get(i+1))) {
|
36 | hl.date = tok.get(i+1); |
37 | print(" Date: " + hl.date);
|
38 | } |
39 | |
40 | if (eqic(t, "<span class=\"time\">") && hl != null) {
|
41 | int j = i+1; |
42 | while (j < l(tok) && !match("*:*:*", tok.get(j)))
|
43 | j += 2; |
44 | if (j < l(tok)) {
|
45 | hl.time = tok.get(j); |
46 | print(" Time: " + hl.time);
|
47 | } |
48 | } |
49 | } |
50 | } |
51 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001864 |
| Snippet name: | Get headlines from blog (works) |
| Eternal ID of this version: | #1001864/1 |
| Text MD5: | 29998506457f5c000832f47f4a072419 |
| Transpilation MD5: | b95c10c30987c6eaca4b23348878e5c5 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-11-30 20:42:02 |
| Source code size: | 1347 bytes / 51 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1011 / 1122 |
| Referenced in: | [show references] |