Uses 64664K of libraries. Click here for Pure Java version (4926L/30K).
1 | sclass GoogleSearch { |
2 | Browser browser; |
3 | S query; |
4 | new MapSO urlParams; |
5 | |
6 | *(Browser *browser, S *query) {} |
7 | |
8 | L<WithURL<S>> search_uncached() { |
9 | S url = appendParamsToURL("https://google.com/search", mapPlus(urlParams, q := query); |
10 | print(url); |
11 | |
12 | temp var page = playwrightOpenPage(browser, url); |
13 | |
14 | L<ElementHandle> links1 = page.querySelectorAll("a[href]:has(h3)"); |
15 | |
16 | LPairS links = mapNonNulls(links1, l -> { |
17 | S link = l.getAttribute("href"); |
18 | if (!isAbsoluteURL(link)) null; |
19 | ret pair(link, trim(htmlDecode_dropTags( |
20 | l.querySelector("h3").innerHTML()))); |
21 | }); |
22 | |
23 | ret map(links, l -> WithURL(l.a, l.b)); |
24 | } |
25 | } |
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: | 186 / 332 |
Version history: | 4 change(s) |
Referenced in: | [show references] |