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

17
LINES

< > BotCompany Repo | #1032450 // googleSearch_all - get all results on first page. uses Playwright. caches query results

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

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

static L<WithURL<S>> googleSearch_all(Browser browser, S query, double cacheExpirationDays default 1) {
  ret googleSearch_all(new GoogleSearch(browser, simpleSpacesAndTrim(lower(query))), cacheExpirationDays);
}

static L<WithURL<S>> googleSearch_all(GoogleSearch gs, double cacheExpirationDays default 1) {
  FileBasedStringMap cache = new(javaxCachesDir("Google Searches"));
  S key = sfu(ll(gs.query, gs.urlParams));
  File f = cache.fileForKey(key);
  if (exists(f) && fileAgeInDays(f) < cacheExpirationDays)
    ret (L) unstructure(cache.get(key));
  
  // not in cache, start browser
  
  var result = gs.search_uncached();
  cache.put(key, indentedStructure(result));
  ret result;
}

Author comment

Began life as a copy of #1032307

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032450
Snippet name: googleSearch_all - get all results on first page. uses Playwright. caches query results
Eternal ID of this version: #1032450/9
Text MD5: 3560b711efc5cca29f61e790dd6e05ff
Transpilation MD5: 3f849fcc4b26deded0787f24b675a119
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-11 20:33:14
Source code size: 707 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 92 / 159
Version history: 8 change(s)
Referenced in: [show references]