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

14
LINES

< > BotCompany Repo | #1032313 // youTubeSearch_uncached - uses Playwright

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

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

static L<WithURL<S>> youTubeSearch_uncached(Browser browser, S query) {
  temp var page = playwrightOpenPage(browser,
    appendParamsToURL("https://www.youtube.com/results", search_query := query));
  L<ElementHandle> links1 = page.querySelectorAll("a[href]");
  LPairS links = map(links1, l -> pair(l.getAttribute("href"), l.innerHTML()));
  links = filter(links, l -> startsWith(l.a, "/watch?") && empty(urlParam(l.a, "list")));
  
  links = mapPairsB htmldecode_dropTagsAndComments_trim(links);
  
  // Filter out weird links
  links = filter(links, l -> !containsNewLine(l.b) && nempty(l.b));

  ret map(links, l -> WithURL("https://www.youtube.com" + l.a, l.b));
}

Author comment

Began life as a copy of #1032307

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032313
Snippet name: youTubeSearch_uncached - uses Playwright
Eternal ID of this version: #1032313/5
Text MD5: f120520cb20dfb4406ba6165da13aa15
Transpilation MD5: 95b63b4032ed0f0e9b45ab99ca9d4877
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-30 04:30:29
Source code size: 683 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 189 / 248
Version history: 4 change(s)
Referenced in: [show references]