nathell / skyscraper

Structural scraping for the rest of us.
410 stars 10 forks source link

Use ns-resolve instead of resolve #4

Closed ayato-p closed 9 years ago

ayato-p commented 9 years ago

This PR is pretty small modification.

The problem is as follows.

(ns ex.proc
  (:require [net.cgrand.enlive-html :as html]
            [skyscraper :as s]))

(s/defprocessor root-page
  :cache-template "/ex"
  :process-fn (fn [res ctx]
                (let [child [html/select res [:a#child]]]
                  [{:url (s/href child)
                    :processor ::child-page}])))

(s/defprocessor child-page
  ;; somecode
  )

(ns ex.core
  (:require [skyscraper :as s]))

(def seed [{:url "http://example.com/"
            :processor :ex.proc/root-page}])

(s/scrape seed) ;; does not working, because `do-scrape` function can't resolve different namespace vars.

Thank you, -- ayato-p

nathell commented 9 years ago

Awesome, thanks! I had a vague idea of something going amiss with namespaces but I didn't get around to fix this.