Advertisement
Guest User

Untitled

a guest
Feb 10th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns proj.core
  2.   (:require [etaoin.api :as sel]
  3.             [clojure.data.json :as json]
  4.             [clojure.java.io :as io]))
  5.  
  6. (def first-run []
  7.     (def browser (sel/chrome))
  8.     (sel/get-cookies browser) ; => NOT EMPY COOKIES [{} {} {}]
  9.     (write-cookie (sel/get-cookies browser)))
  10.  
  11.  
  12. (def second-run []
  13.     (def browser (sel/chrome))
  14.     (sel/get-cookies browser) ; => EMPY COOKIES []
  15.     (sel/set-cookie browser (get (read-cookie) 0)) ; => Exception
  16.     ; ExceptionInfo throw+: {:response {:sessionId "1e119f7d0cec7706fcbf5a0ce403a733", :status 24, :value
  17.     ; {:message "invalid  cookie domain\n ........
  18. )
  19.  
  20. (def cookies-file (io/resource "cookies.json"))
  21.  
  22. (defn write-cookie [cookie]
  23.   (let [str-data (json/write-str cookie)]
  24.     (spit cookies-file str-data)))
  25.  
  26. (defn read-cookie []
  27.   (let [str-data (slurp cookies-file)]
  28.     (json/read-str str-data)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement