1 | sclass OneLiner { |
2 | S userName; |
3 | S contents; // html |
4 | } |
5 | |
6 | // get the 5 one-liners from home page |
7 | static L<OneLiner> pouetOneLiners() { |
8 | ret pouetOneLiners(loadPageWithUserAgent("http://pouet.net", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0")); |
9 | } |
10 | |
11 | static L<OneLiner> pouetOneLiners(S html) { |
12 | new L<OneLiner> out; |
13 | L<S> tok = htmlTok(html); |
14 | |
15 | int i = tok.indexOf("<div class='pouettbl' id='pouetbox_latestoneliner'>"); |
16 | if (i >= 0) { |
17 | int j = findEndOfContainerTag(tok, i); |
18 | if (j >= 0) { |
19 | L<S> tok2 = subList(tok, i+1, j-1); |
20 | //psl(tok2); |
21 | L<L<S>> l = unwrapContainerTags(findContainerTag(tok2, "li")); |
22 | for (L<S> tok3 : l) pcall { |
23 | psl(tok3); |
24 | int k = indexOf(tok3, "</a>"); |
25 | new OneLiner o; |
26 | o.userName = getHtmlTagParameter(tok3.get(1), "title"); |
27 | o.contents = trim(join(subList(tok3, k+1))); |
28 | out.add(o); |
29 | } |
30 | } |
31 | } |
32 | ret out; |
33 | } |
Began life as a copy of #1005219
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005225 |
Snippet name: | pouetOneLiners |
Eternal ID of this version: | #1005225/2 |
Text MD5: | dbf8782702acf2e528c111958122f5d8 |
Author: | stefan |
Category: | javax / web scraping |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-01-15 15:49:27 |
Source code size: | 978 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 607 / 564 |
Version history: | 1 change(s) |
Referenced in: | [show references] |