Libraryless. Click here for Pure Java version (5775L/41K/130K).
1 | !752 |
2 | |
3 | p { bot(); } |
4 | |
5 | static class GoogleResult { |
6 | S unescapedUrl, cacheUrl, titleNoFormatting; |
7 | } |
8 | |
9 | answer { |
10 | if (matchStart("quickgoogle", s, m)) { |
11 | S query = m.rest(); |
12 | S url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + urlencode(query); |
13 | S json = loadPage(url); |
14 | |
15 | // json fumbling |
16 | Map data = jsonDecodeMap(json); |
17 | Map responseData =cast data.get("responseData"); |
18 | List<Map> _results = cast responseData.get("results"); |
19 | |
20 | new L<GoogleResult> results; |
21 | new StringBuilder buf; |
22 | for (int i = 0; i < _results.size(); i++) { |
23 | Map row = _results.get(i); |
24 | //print(structure(row)); |
25 | new GoogleResult r; |
26 | r.unescapedUrl = (S) row.get("unescapedUrl"); |
27 | r.cacheUrl = (S) row.get("cacheUrl"); |
28 | r.titleNoFormatting = htmldecode((S) row.get("titleNoFormatting")); |
29 | results.add(r); |
30 | //buf.append(r.titleNoFormatting + " [" + r.unescapedUrl + "]\n"); |
31 | buf.append(r.titleNoFormatting + "\n " + r.unescapedUrl + "\n"); |
32 | } |
33 | |
34 | //ret structure(results); |
35 | ret slackSnippet(buf); |
36 | } |
37 | } |
Began life as a copy of #1000857
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002508 |
Snippet name: | Direct Google Search Bot [doesn't work anymore] |
Eternal ID of this version: | #1002508/3 |
Text MD5: | 54a0587b0109681a5858bdd6771a0d9a |
Transpilation MD5: | 57cf9c72aa7bdd5c90f28eb09ce59672 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-16 00:38:21 |
Source code size: | 1116 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 642 / 1185 |
Version history: | 2 change(s) |
Referenced in: | [show references] |