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).

1  
static L<WithURL<S>> googleSearch_all(Browser browser, S query, double cacheExpirationDays default 1) {
2  
  ret googleSearch_all(new GoogleSearch(browser, simpleSpacesAndTrim(lower(query))), cacheExpirationDays);
3  
}
4  
5  
static L<WithURL<S>> googleSearch_all(GoogleSearch gs, double cacheExpirationDays default 1) {
6  
  FileBasedStringMap cache = new(javaxCachesDir("Google Searches"));
7  
  S key = sfu(ll(gs.query, gs.urlParams));
8  
  File f = cache.fileForKey(key);
9  
  if (exists(f) && fileAgeInDays(f) < cacheExpirationDays)
10  
    ret (L) unstructure(cache.get(key));
11  
  
12  
  // not in cache, start browser
13  
  
14  
  var result = gs.search_uncached();
15  
  cache.put(key, indentedStructure(result));
16  
  ret result;
17  
}

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: 165 / 255
Version history: 8 change(s)
Referenced in: [show references]