Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding infibeam

  • Loading branch information...
commit dc6127849fd6b7ff77e55f753518737f25cd4191 1 parent aededcf
@swaroopch authored
Showing with 31 additions and 4 deletions.
  1. +6 −0 resources/book.mustache
  2. +25 −4 src/isbnnetinclj2/store.clj
View
6 resources/book.mustache
@@ -66,6 +66,12 @@
<td>{{priceFlipkart}}</td>
</tr>
{{/priceFlipkart}}
+ {{#priceInfibeam}}
+ <tr>
+ <th>Infibeam</th>
+ <td>{{priceInfibeam}}</td>
+ </tr>
+ {{/priceInfibeam}}
</table>
</div>
</div>
View
29 src/isbnnetinclj2/store.clj
@@ -86,10 +86,31 @@
:binding (get flipkart-values "Binding")}))
+(defn infibeam-url
+ [isbn]
+ (format
+ "http://www.infibeam.com/search.jsp?storeName=Books&query=%s"
+ isbn))
+
+
+(defn fetch-infibeam
+ [isbn]
+ (log/debug (format "Fetching infibeam for %s" isbn))
+ (let [url (infibeam-url isbn)
+ content (utils/fetch-page url)]
+ {:priceInfibeam (parse-price-from-content
+ content
+ [:span.infiPrice])}))
+
+
(defn book-page
[isbn]
- (let [flipkart-details (fetch-flipkart isbn)]
+ (let [flipkart-details (fetch-flipkart isbn)
+ infibeam-details (fetch-infibeam isbn)]
(mus/render-file "book"
- (merge {:isbn isbn
- :pageTitle (:title flipkart-details)}
- flipkart-details))))
+ (reduce
+ merge
+ {:isbn isbn
+ :pageTitle (:title flipkart-details)}
+ [flipkart-details
+ infibeam-details]))))
Please sign in to comment.
Something went wrong with that request. Please try again.