book_finder_api 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/book_finder_api/version.rb +1 -1
- data/lib/book_finder_api.rb +15 -5
- metadata +1 -1
data/lib/book_finder_api.rb
CHANGED
@@ -27,8 +27,12 @@ class BookFinder
|
|
27
27
|
#getting the titles and author
|
28
28
|
title_div=page.search(".mprod-summary-title")
|
29
29
|
result["Book"]=title_div.search("h1").text()
|
30
|
-
|
31
|
-
|
30
|
+
book_authors=[]
|
31
|
+
authors=title_div.search("h2")
|
32
|
+
authors.each do |author|
|
33
|
+
book_authors << author.text()
|
34
|
+
end
|
35
|
+
result["Author"]=book_authors.join(",")
|
32
36
|
#storing the resluts
|
33
37
|
page.search(".fk-specs-type2 tr").each do |tr|
|
34
38
|
fk_key=tr.search(".specs-key").text()
|
@@ -63,18 +67,24 @@ class BookFinder
|
|
63
67
|
result["img_url"]=img_url.to_s
|
64
68
|
end
|
65
69
|
puts "#{result['img_url']} is image url"
|
66
|
-
if result["img_url"]
|
67
|
-
img_tag=page.search("
|
70
|
+
if result["img_url"]==""
|
71
|
+
img_tag=page.search("#mprodimg-id")
|
72
|
+
img=img_tag.search("img")
|
68
73
|
puts img_tag
|
69
74
|
puts "inside"
|
70
|
-
img_url=
|
75
|
+
img_url=img.attribute("src")
|
71
76
|
result["img_url"]=img_url.to_s
|
72
77
|
end
|
73
78
|
|
74
79
|
#storing the price
|
75
80
|
price=page.search("#fk-mprod-list-id").text()
|
76
81
|
if price ==""
|
82
|
+
puts "first price empty"
|
77
83
|
price = page.search("#fk-mprod-our-id").text()
|
84
|
+
if price==""
|
85
|
+
puts "second price"
|
86
|
+
price=page.search(".fk-font-finalprice").text()
|
87
|
+
end
|
78
88
|
end
|
79
89
|
price.delete!("Rs. ")
|
80
90
|
result["price"]=price
|