Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns proj.core
- (:require [etaoin.api :as sel]
- [clojure.data.json :as json]
- [clojure.java.io :as io]))
- (def first-run []
- (def browser (sel/chrome))
- (sel/get-cookies browser) ; => NOT EMPY COOKIES [{} {} {}]
- (write-cookie (sel/get-cookies browser)))
- (def second-run []
- (def browser (sel/chrome))
- (sel/get-cookies browser) ; => EMPY COOKIES []
- (sel/set-cookie browser (get (read-cookie) 0)) ; => Exception
- ; ExceptionInfo throw+: {:response {:sessionId "1e119f7d0cec7706fcbf5a0ce403a733", :status 24, :value
- ; {:message "invalid cookie domain\n ........
- )
- (def cookies-file (io/resource "cookies.json"))
- (defn write-cookie [cookie]
- (let [str-data (json/write-str cookie)]
- (spit cookies-file str-data)))
- (defn read-cookie []
- (let [str-data (slurp cookies-file)]
- (json/read-str str-data)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement