Created
February 15, 2016 15:05
-
-
Save edbond/03f21089faf3e7923574 to your computer and use it in GitHub Desktop.
This file contains 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
(defn make-screenshots-xf [] | |
(fn [xf] | |
(let [_ (debug "Starting new browser") | |
browser (new-driver {:browser :chrome})] | |
(debug "New browser Maximize") | |
(maximize browser) | |
(fn | |
([] | |
(debug "Init") | |
(xf)) | |
([result] | |
(debug "Finalize" result) | |
;; (taxi/quit browser) | |
(xf result)) | |
([result input] | |
(debug "Called save-screenshot with input: " input) | |
(xf result input) | |
(try | |
(let [filename (str "details/" (first input) "/" input ".png")] | |
(make-parents filename) | |
(to browser (str "http://www.google.com/users/" input "/details")) | |
(taxi/wait-until browser (fn [x] | |
(taxi/exists? browser "table.alerts th")) 5000 0) | |
;; (taxi/implicit-wait browser 1000) | |
(take-screenshot browser :file filename) | |
(xf result {input :ok})) | |
(catch Exception e | |
(xf result {input e})))))))) | |
(defn -main [& args] | |
(let [from (chan) | |
to (chan) | |
xf (make-screenshots-xf) | |
n 64] | |
;; (sequence make-screenshots-xf tickers) | |
(prn "Starting pipeline") | |
(async/pipeline-blocking n to xf from) | |
(prn "Copy input tickers " tickers " (" (count tickers) ") onto " from) | |
(async/onto-chan from tickers) | |
(prn "Waiting for results") | |
(time | |
(let [results (async/<!! (async/into [] to))] | |
(pprint results (writer "results.txt")) | |
(prn "Results " results))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment