Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

43
LINES

< > BotCompany Repo | #1000857 // Google search test

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (457L/4K/12K).

!747

m {
  // in
  static S query = "Java class declarations";
  
  // intermediate
  static S url, json;
  
  // out
  static O data;
  static new List<GoogleResult> results;
  
  static class GoogleResult {
    S url, cacheurl, title;
  }
  
  p {
    url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" + urlencode(query);
    json = loadPage(url);
    //print(json);
    //print();
    data = jsonDecode(json);
    //print(structure(data));
    
    O responseData = ((Map) data).get("responseData");
    //print(structure(responseData));
    
    List<Map> _results = cast ((Map) responseData).get("results");
    //print(structure(_results));
    
    for (int i = 0; i < _results.size(); i++) {
      Map row = _results.get(i);
      //print(structure(row));
      new GoogleResult r;
      r.url = (S) row.get("unescapedUrl");
      r.cacheurl = (S) row.get("cacheUrl");
      r.title = (S) row.get("titleNoFormatting");
      print(structure(r));
      results.add(r);
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, liwcxgsjrgqn, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000857
Snippet name: Google search test
Eternal ID of this version: #1000857/1
Text MD5: 8bfe79fe615f0ecb171bbe8a2904cf30
Transpilation MD5: 57277ec6daeb4225f169c6974791bc91
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-30 18:06:39
Source code size: 1049 bytes / 43 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 750 / 863
Referenced in: [show references]