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