Last active
          May 22, 2023 02:47 
        
      - 
      
 - 
        
Save apeckham/ec1725b22642d9344e294c701de18fb2 to your computer and use it in GitHub Desktop.  
    https://github.com/GoogleChrome/puppeteer#usage in clojurescript
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | node_modules | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | yarn init | |
| yarn add puppeteer | |
| yarn add q | |
| brew install lumo | |
| lumo puppeteer.cljs | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "name": "puppeteer-poc", | |
| "version": "1.0.0", | |
| "main": "index.js", | |
| "repository": "[email protected]:ec1725b22642d9344e294c701de18fb2.git", | |
| "author": "apeckham <[email protected]>", | |
| "license": "MIT", | |
| "dependencies": { | |
| "puppeteer": "^0.10.2", | |
| "q": "^1.5.0" | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | ;; to avoid "Octal literals are not allowed in strict mode." | |
| ;; https://github.com/anmonteiro/lumo/issues/28 | |
| (.setFlagsFromString (js/require "v8") "--no-use_strict") | |
| (def puppeteer (js/require "puppeteer")) | |
| (def Q (js/require "q")) | |
| (-> (Q (.launch puppeteer)) | |
| (.then (fn [browser] | |
| (-> (Q (.newPage browser)) | |
| (.then (fn [page] | |
| (.goto page "https://example.com/") | |
| (.screenshot page #js {:path "example.png"}))) | |
| (.then #(.close browser)))))) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | |
| # yarn lockfile v1 | |
| agent-base@^4.1.0: | |
| version "4.1.1" | |
| resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.1.1.tgz#92d8a4fc2524a3b09b3666a33b6c97960f23d6a4" | |
| dependencies: | |
| es6-promisify "^5.0.0" | |
| balanced-match@^1.0.0: | |
| version "1.0.0" | |
| resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" | |
| brace-expansion@^1.1.7: | |
| version "1.1.8" | |
| resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.8.tgz#c07b211c7c952ec1f8efd51a77ef0d1d3990a292" | |
| dependencies: | |
| balanced-match "^1.0.0" | |
| concat-map "0.0.1" | |
| [email protected]: | |
| version "0.0.1" | |
| resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" | |
| [email protected]: | |
| version "1.6.0" | |
| resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" | |
| dependencies: | |
| inherits "^2.0.3" | |
| readable-stream "^2.2.2" | |
| typedarray "^0.0.6" | |
| core-util-is@~1.0.0: | |
| version "1.0.2" | |
| resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" | |
| [email protected]: | |
| version "2.2.0" | |
| resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" | |
| dependencies: | |
| ms "0.7.1" | |
| debug@^2.4.1, debug@^2.6.8: | |
| version "2.6.8" | |
| resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" | |
| dependencies: | |
| ms "2.0.0" | |
| es6-promise@^4.0.3: | |
| version "4.1.1" | |
| resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.1.tgz#8811e90915d9a0dba36274f0b242dbda78f9c92a" | |
| es6-promisify@^5.0.0: | |
| version "5.0.0" | |
| resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" | |
| dependencies: | |
| es6-promise "^4.0.3" | |
| extract-zip@^1.6.5: | |
| version "1.6.5" | |
| resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.5.tgz#99a06735b6ea20ea9b705d779acffcc87cff0440" | |
| dependencies: | |
| concat-stream "1.6.0" | |
| debug "2.2.0" | |
| mkdirp "0.5.0" | |
| yauzl "2.4.1" | |
| fd-slicer@~1.0.1: | |
| version "1.0.1" | |
| resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" | |
| dependencies: | |
| pend "~1.2.0" | |
| fs.realpath@^1.0.0: | |
| version "1.0.0" | |
| resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" | |
| glob@^7.0.5: | |
| version "7.1.2" | |
| resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" | |
| dependencies: | |
| fs.realpath "^1.0.0" | |
| inflight "^1.0.4" | |
| inherits "2" | |
| minimatch "^3.0.4" | |
| once "^1.3.0" | |
| path-is-absolute "^1.0.0" | |
| https-proxy-agent@^2.1.0: | |
| version "2.1.0" | |
| resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.1.0.tgz#1391bee7fd66aeabc0df2a1fa90f58954f43e443" | |
| dependencies: | |
| agent-base "^4.1.0" | |
| debug "^2.4.1" | |
| inflight@^1.0.4: | |
| version "1.0.6" | |
| resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" | |
| dependencies: | |
| once "^1.3.0" | |
| wrappy "1" | |
| inherits@2, inherits@^2.0.3, inherits@~2.0.3: | |
| version "2.0.3" | |
| resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" | |
| isarray@~1.0.0: | |
| version "1.0.0" | |
| resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" | |
| mime@^1.3.4: | |
| version "1.4.0" | |
| resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.0.tgz#69e9e0db51d44f2a3b56e48b7817d7d137f1a343" | |
| minimatch@^3.0.4: | |
| version "3.0.4" | |
| resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" | |
| dependencies: | |
| brace-expansion "^1.1.7" | |
| [email protected]: | |
| version "0.0.8" | |
| resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" | |
| [email protected]: | |
| version "0.5.0" | |
| resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" | |
| dependencies: | |
| minimist "0.0.8" | |
| [email protected]: | |
| version "0.7.1" | |
| resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" | |
| [email protected]: | |
| version "2.0.0" | |
| resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" | |
| once@^1.3.0: | |
| version "1.4.0" | |
| resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" | |
| dependencies: | |
| wrappy "1" | |
| path-is-absolute@^1.0.0: | |
| version "1.0.1" | |
| resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" | |
| pend@~1.2.0: | |
| version "1.2.0" | |
| resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" | |
| process-nextick-args@~1.0.6: | |
| version "1.0.7" | |
| resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" | |
| progress@^2.0.0: | |
| version "2.0.0" | |
| resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" | |
| proxy-from-env@^1.0.0: | |
| version "1.0.0" | |
| resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" | |
| puppeteer@^0.10.2: | |
| version "0.10.2" | |
| resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-0.10.2.tgz#b4a959a722bf626ca481f2aeba11fdb810f2c98f" | |
| dependencies: | |
| debug "^2.6.8" | |
| extract-zip "^1.6.5" | |
| https-proxy-agent "^2.1.0" | |
| mime "^1.3.4" | |
| progress "^2.0.0" | |
| proxy-from-env "^1.0.0" | |
| rimraf "^2.6.1" | |
| ws "^3.0.0" | |
| q@^1.5.0: | |
| version "1.5.0" | |
| resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1" | |
| readable-stream@^2.2.2: | |
| version "2.3.3" | |
| resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" | |
| dependencies: | |
| core-util-is "~1.0.0" | |
| inherits "~2.0.3" | |
| isarray "~1.0.0" | |
| process-nextick-args "~1.0.6" | |
| safe-buffer "~5.1.1" | |
| string_decoder "~1.0.3" | |
| util-deprecate "~1.0.1" | |
| rimraf@^2.6.1: | |
| version "2.6.1" | |
| resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" | |
| dependencies: | |
| glob "^7.0.5" | |
| safe-buffer@~5.1.0, safe-buffer@~5.1.1: | |
| version "5.1.1" | |
| resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" | |
| string_decoder@~1.0.3: | |
| version "1.0.3" | |
| resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" | |
| dependencies: | |
| safe-buffer "~5.1.0" | |
| typedarray@^0.0.6: | |
| version "0.0.6" | |
| resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" | |
| ultron@~1.1.0: | |
| version "1.1.0" | |
| resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.0.tgz#b07a2e6a541a815fc6a34ccd4533baec307ca864" | |
| util-deprecate@~1.0.1: | |
| version "1.0.2" | |
| resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" | |
| wrappy@1: | |
| version "1.0.2" | |
| resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" | |
| ws@^3.0.0: | |
| version "3.1.0" | |
| resolved "https://registry.yarnpkg.com/ws/-/ws-3.1.0.tgz#8afafecdeab46d572e5397ee880739367aa2f41c" | |
| dependencies: | |
| safe-buffer "~5.1.0" | |
| ultron "~1.1.0" | |
| [email protected]: | |
| version "2.4.1" | |
| resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" | |
| dependencies: | |
| fd-slicer "~1.0.1" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
hey, thanks for your example !
you should add a
#js {:waitUntil "load"}to thegotocall in order to make sure page has been loaded