clojure-soup icon indicating copy to clipboard operation
clojure-soup copied to clipboard

'$' Macro not working unless using literals

Open javahippie opened this issue 9 years ago • 0 comments

I tried crawling a page with clojure-soup the following way:

(defn get-offers
  "Returns the current offers from the page"
  []
  (let [uri "https://google.com"
        selector "input" ]
    ($ (get! uri) selector)))

It returned zero entries. It only was successful after changing it to this:

(defn get-offers
  "Returns the current offers from the page"
  []
  (let [uri "https://google.com"]
    ($ (get! uri) "input")))

It seems that the macros behavior changes due to the type of the parameter, and the evaluation fails when you do not declare it as a string literal? Right now, I am working around it with following code:

(defn get-offers
  "Returns the current offers from the page"
  []
  (let [uri "https://google.com"
        selector "input" ]
    (.select (get! uri) selector)))

 

javahippie avatar Dec 28 '16 10:12 javahippie