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

Commit

Permalink
Adding snapdeal + boilerplate for Amazon.in
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopch committed Jul 27, 2013
1 parent 39c6f61 commit d3e7206
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
12 changes: 12 additions & 0 deletions resources/book.mustache
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
<td>{{priceHomeshop18}}</td> <td>{{priceHomeshop18}}</td>
</tr> </tr>
{{/priceHomeshop18}} {{/priceHomeshop18}}
{{#priceSnapdeal}}
<tr>
<th>Snapdeal</th>
<td>{{priceSnapdeal}}</td>
</tr>
{{/priceSnapdeal}}
{{#priceAmazonIndia}}
<tr>
<th>AmazonIndia</th>
<td>{{priceAmazonIndia}}</td>
</tr>
{{/priceAmazonIndia}}
</table> </table>
</div> </div>
</div> </div>
Expand Down
41 changes: 39 additions & 2 deletions src/isbnnetinclj2/store.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,16 +121,53 @@
[:span#hs18Price])})) [:span#hs18Price])}))




(defn snapdeal-url
[isbn]
(format
"http://www.snapdeal.com/search?keyword=%s&santizedKeyword=&catId=&categoryId=364&suggested=false&vertical=p&noOfResults=20&clickSrc=go_header&lastKeyword=&prodCatId=&changeBackToAll=false&foundInAll=false&categoryIdSearched=&cityPageUrl=&url=&utmContent=&catalogID=&dealDetail="
isbn))


(defn fetch-snapdeal
[isbn]
(log/debug (format "Fetching snapdeal for %s" isbn))
(let [url (snapdeal-url isbn)
content (utils/fetch-page url)]
{:priceSnapdeal (parse-price-from-content
content
[:div.product_price])}))


(defn amazon-india-url
[isbn]
(format
"http://www.amazon.in/s/ref=nb_sb_noss?url=search-alias%%3Dstripbooks&amp;field-keywords=%s"
isbn))


;;; TODO How to follow redirects?
(defn fetch-amazon-india
[isbn]
(log/debug (format "Fetching amazon-india for %s" isbn))
(let [url (amazon-india-url isbn)
content (utils/fetch-page url)]
{:priceAmazonIndia (parse-price-from-content
content
[:span.bld.lrg.red])}))


(defn book-page (defn book-page
[isbn] [isbn]
(let [flipkart-details (fetch-flipkart isbn) (let [flipkart-details (fetch-flipkart isbn)
infibeam-details (fetch-infibeam isbn) infibeam-details (fetch-infibeam isbn)
homeshop18-details (fetch-homeshop18 isbn)] homeshop18-details (fetch-homeshop18 isbn)
snapdeal-details (fetch-snapdeal isbn)]
(mus/render-file "book" (mus/render-file "book"
(reduce (reduce
merge merge
{:isbn isbn {:isbn isbn
:pageTitle (:title flipkart-details)} :pageTitle (:title flipkart-details)}
[flipkart-details [flipkart-details
infibeam-details infibeam-details
homeshop18-details])))) homeshop18-details
snapdeal-details]))))

0 comments on commit d3e7206

Please sign in to comment.