static int tbSearch_defaultMax = 3; static new ThreadLocal tbSearch_quick; static new ThreadLocal tbSearch_html; static L tbSearch(S query) { ret tbSearch(tbSearch_defaultMax, query); } static L 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 tbSearch_url(S url) { S page = loadPage(url); if (eq(tbSearch_html!, "want")) tbSearch_html.set(page); Matcher m = Pattern.compile(">(#\\d+) - (.*?)
").matcher(page); new L results; while (m.find()) results.add(new Snippet( m.group(1), htmldecode(dropTags(m.group(2))), null)); // no md5 for now ret results; }