Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
devn committed Nov 30, 2013
1 parent caeeab3 commit af80715
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions README.markdown
Expand Up @@ -6,36 +6,40 @@

## getting started

In your `project.clj`: `[yokogiri "1.5.2"]`
In your `project.clj`: `[yokogiri "1.5.4"]`
```clojure
(ns myproject.core
(:require [yokogiri.core :as yokogiri]))
(ns myproject.core
(:require [yokogiri.core :as yokogiri]))
```
or
```clojure
(ns myproject.core
(:use [yokogiri.core]))
(ns myproject.core
(:use [yokogiri.core]))
```

## usage
```clojure
(def client (yokogiri/make-client))

(def page (yokogiri/get-page client "http://example.com"))

;; xpath
(def anchor-node-text (map node-text (xpath page "//a")))

;; css
(def footer-feedback-text
(map node-text (css page "div.footer-beta-feedback")))

;; get specific attributes
(def a-attr-href
(map #(select-keys % [:href]) (map attr-map (css page "div.link a"))))
(def client (make-client))

;; with javascript enabled (see source for additional options):
(def client (make-client :javascript true))

(def page (get-page client "http://example.com"))

;; xpath
(def anchor-node-text (map node-text (xpath page "//a")))

;; css
(def footer-feedback-text
(map node-text (css page "div.footer-beta-feedback")))

;; get specific attributes
(def a-attr-href
(map #(select-keys (attr-map %) [:href])
(-> page css "div.link a")))
```
## license

Copyright (C) 2012 Devin Walters
Copyright (C) 2013 Devin Walters

Distributed under the Eclipse Public License, the same as Clojure.

0 comments on commit af80715

Please sign in to comment.