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

25
LINES

< > BotCompany Repo | #1032504 // GoogleSearch - replacement of googleSearch_uncached. uses Playwright

JavaX fragment (include) [tags: use-pretranspiled]

Uses 64664K of libraries. Click here for Pure Java version (4926L/30K).

sclass GoogleSearch {
  Browser browser;
  S query;
  new MapSO urlParams;
  
  *(Browser *browser, S *query) {}
  
  L<WithURL<S>> search_uncached() {
    S url = appendParamsToURL("https://google.com/search", mapPlus(urlParams, q := query);
    print(url);
    
    temp var page = playwrightOpenPage(browser, url);
      
    L<ElementHandle> links1 = page.querySelectorAll("a[href]:has(h3)");
    
    LPairS links = mapNonNulls(links1, l -> {
      S link = l.getAttribute("href");
      if (!isAbsoluteURL(link)) null;
      ret pair(link, trim(htmlDecode_dropTags(
        l.querySelector("h3").innerHTML())));
    });
    
    ret map(links, l -> WithURL(l.a, l.b));
  }
}

Author comment

Began life as a copy of #1032447

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032504
Snippet name: GoogleSearch - replacement of googleSearch_uncached. uses Playwright
Eternal ID of this version: #1032504/5
Text MD5: 3c2a15685c7d074b5bf3af7eba75edee
Transpilation MD5: 4bc26719f132685eebef62db9e4e2a00
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-14 00:00:53
Source code size: 704 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 185 / 330
Version history: 4 change(s)
Referenced in: [show references]