Permalink
Browse files

Flipkart info parsing now works

  • Loading branch information...
swaroopch committed Jul 27, 2013
1 parent 188f0ec commit aededcf98728bbc27c2c33c2487c8bb353a81036
Showing with 29 additions and 2 deletions.
  1. +10 −0 resources/book.mustache
  2. +19 −2 src/isbnnetinclj2/store.clj
View
@@ -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">
@@ -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
@@ -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

0 comments on commit aededcf

Please sign in to comment.