Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

Commit

Permalink
Flipkart info parsing now works
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopch committed Jul 27, 2013
1 parent 188f0ec commit aededcf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
10 changes: 10 additions & 0 deletions resources/book.mustache
Expand Up @@ -23,6 +23,16 @@
<dt>Publisher</dt>
<dd>{{publisher}}</dd>
{{/publisher}}

{{#year}}
<dt>Year</dt>
<dd>{{year}}</dd>
{{/year}}

{{#binding}}
<dt>Binding</dt>
<dd>{{binding}}</dd>
{{/binding}}
</dl>
</div>
<div class="span4">
Expand Down
21 changes: 19 additions & 2 deletions src/isbnnetinclj2/store.clj
Expand Up @@ -49,11 +49,24 @@
isbn))


;;; TODO Convert keys to keywords
(defn pick-flipkart-values
[content]
(apply
hash-map
(map
(comp html/text first :content)
(html/select
content
[:table.fk-specs-type2 #{:td.specs-key :td.specs-value}]))))


(defn fetch-flipkart
[isbn]
(log/debug (format "Fetching flipkart for %s" isbn))
(let [url (flipkart-url isbn)
content (utils/fetch-page url)]
content (utils/fetch-page url)
flipkart-values (pick-flipkart-values content)]
{:isbn isbn
:title (parse-text-from-content
content
Expand All @@ -66,7 +79,11 @@
[:attrs :data-src])
:priceFlipkart (parse-price-from-content
content
[:div.prices :span.fk-font-finalprice])}))
[:div.prices :span.fk-font-finalprice])
:author (get flipkart-values "Author")
:publisher (get flipkart-values "Publisher")
:year (get flipkart-values "Publication Year")
:binding (get flipkart-values "Binding")}))


(defn book-page
Expand Down

0 comments on commit aededcf

Please sign in to comment.