static int tbSearch_defaultMax = 3; static new ThreadLocal<Bool> tbSearch_quick; static new ThreadLocal<S> tbSearch_html; static L<Snippet> tbSearch(S query) { ret tbSearch(tbSearch_defaultMax, query); } static L<Snippet> tbSearch(int max, S query) { bool quick = isTrue(getAndClearThreadLocal(tbSearch_quick)); S url = tb_mainServer() + "/tb/search.php?q=" + urlencode(query) + "&limit=" + max + (quick ? "&quick=1" : "") + standardCredentials(); ret tbSearch_url(url); } static L<Snippet> tbSearch_url(S url) { S page = loadPage(url); if (eq(tbSearch_html!, "want")) tbSearch_html.set(page); Matcher m = Pattern.compile(">(#\\d+)</a> - (.*?)<br>").matcher(page); new L<Snippet> results; while (m.find()) results.add(new Snippet( m.group(1), htmldecode(dropTags(m.group(2))), null)); // no md5 for now ret results; }
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: | 597 / 620 |
Version history: | 5 change(s) |
Referenced in: | #1003966 - tbSearchRunnable - searches runnable snippets #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1020385 - tbSearch_v2 - with standard classes + functions |