1 | static int tbSearch_defaultMax = 3; |
2 | static new ThreadLocal<Bool> tbSearch_quick; |
3 | static new ThreadLocal<S> tbSearch_html; |
4 | |
5 | static L<Snippet> tbSearch(S query) { |
6 | ret tbSearch(tbSearch_defaultMax, query); |
7 | } |
8 | |
9 | static L<Snippet> tbSearch(int max, S query) { |
10 | bool quick = isTrue(getAndClearThreadLocal(tbSearch_quick)); |
11 | S url = tb_mainServer() + "/tb/search.php?q=" + urlencode(query) + "&limit=" + max + (quick ? "&quick=1" : "") + standardCredentials(); |
12 | ret tbSearch_url(url); |
13 | } |
14 | |
15 | static L<Snippet> tbSearch_url(S url) { |
16 | S page = loadPage(url); |
17 | if (eq(tbSearch_html!, "want")) |
18 | tbSearch_html.set(page); |
19 | Matcher m = Pattern.compile(">(#\\d+)</a> - (.*?)<br>").matcher(page); |
20 | |
21 | new L<Snippet> results; |
22 | while (m.find()) |
23 | results.add(new Snippet( |
24 | m.group(1), |
25 | htmldecode(dropTags(m.group(2))), |
26 | null)); // no md5 for now |
27 | ret results; |
28 | } |
Began life as a copy of #1002569
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1003925 |
Snippet name: | tbSearch - searches snippets, returns ids and names |
Eternal ID of this version: | #1003925/6 |
Text MD5: | 03fc186b679c1cd84038d51275f343b3 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-27 13:50:55 |
Source code size: | 898 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 596 / 620 |
Version history: | 5 change(s) |
Referenced in: | [show references] |