static int tbSearch_v2_defaultMax = 3; static new ThreadLocal<Bool> tbSearch_v2_quick; static new ThreadLocal<S> tbSearch_v2_html; static L<Snippet> tbSearch_v2(S query) { ret tbSearch_v2(tbSearch_v2_defaultMax, query); } static L<Snippet> tbSearch_v2(int max, S query) { bool quick = isTrue(getAndClearThreadLocal(tbSearch_v2_quick)); S url = tb_mainServer() + "/tb/search.php?q=" + urlencode(query) + "&limit=" + max + "&quick=" + (quick ? 1 : 0) + standardCredentials(); ret tbSearch_v2_url(url); } static L<Snippet> tbSearch_v2_url(S url) { S page = loadPage(url); if (eq(tbSearch_v2_html!, "want")) tbSearch_v2_html.set(page); new L<Snippet> results; Matcher m = Pattern.compile("<a href=\"http://code.botcompany.de/(\\d+)\"><b>(.*?)</b>").matcher(page); while (m.find()) results.add(new Snippet( fsI(m.group(1)), htmldecode(dropTags(m.group(2))), null)); m = Pattern.compile(">(#\\d+)</a> - (.*?)<br>").matcher(page); 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 #1003925
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020385 |
Snippet name: | tbSearch_v2 - with standard classes + functions |
Eternal ID of this version: | #1020385/7 |
Text MD5: | b8599764acbad5fcd88d7bb59019d796 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-24 15:48:06 |
Source code size: | 1173 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 334 / 381 |
Version history: | 6 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |