book_finder_api 0.0.14 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module BookFinderApi
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
@@ -26,6 +26,7 @@ class BookFinder
26
26
 
27
27
  #getting the titles and author
28
28
  title_div=page.search(".mprod-summary-title")
29
+ puts "BOOK:#{title_div.search('h1').text()}"
29
30
  result["Book"]=title_div.search("h1").text()
30
31
  book_authors=[]
31
32
  authors=title_div.search("h2")
@@ -48,48 +49,38 @@ class BookFinder
48
49
 
49
50
 
50
51
  if breadcrumb.count >0
51
- result['college']=breadcrumb[4].search("span").text()
52
- if(breadcrumb[5])
53
- result['stream']= breadcrumb[5].search("span").text()
54
- end
52
+ result['college']=breadcrumb[4].search("span").text() if breadcrumb[4]
53
+ result['stream']= breadcrumb[5].search("span").text() if breadcrumb[5]
55
54
  if generals.include? (result['college'])
56
55
  result['college']=breadcrumb[5].search("span").text()
57
- if(breadcrumb[6])
58
- result['stream']= breadcrumb[6].search("span").text()
59
- end
56
+ result['stream']= breadcrumb[6].search("span").text() if(breadcrumb[6])
60
57
  end
61
58
  end
62
59
 
63
60
  #storing the image
64
- page.search("#main-image-id").each do |img_id|
65
- img_tag=img_id.search("img")
66
- img_url=img_tag.attribute("src")
67
- result["img_url"]=img_url.to_s
68
- end
61
+ img_tag=page.search("#mprodimg-id")
62
+ img = img_tag.search("img")
63
+ img_url = img.attribute("data-src")
64
+ result["img_url"]=img_url.to_s
69
65
  puts "#{result['img_url']} is image url"
70
66
  if result["img_url"]==""
71
- img_tag=page.search("#mprodimg-id")
72
- img=img_tag.search("img")
73
- puts img_tag
74
- puts "inside"
75
- img_url=img.attribute("src")
76
- result["img_url"]=img_url.to_s
67
+ page.search("#main-image-id").each do |img_id|
68
+ img_tag=img_id.search("img")
69
+ img_url=img_tag.attribute("src")
70
+ result["img_url"]=img_url.to_s
71
+ puts "Secondary Image: #{result['img_url']} is image url"
72
+ end
77
73
  end
78
74
 
79
75
  #storing the price
80
- price=page.search("#fk-mprod-list-id").text()
81
- if price ==""
82
- puts "first price empty"
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
88
- end
76
+ price = page.search("#fk-mprod-list-id").text()
77
+ price = page.search("#fk-mprod-our-id").text() if price ==""
78
+ price = page.search(".fk-font-finalprice").text() if price ==""
79
+
89
80
  price.delete!("Rs. ")
90
- result["price"]=price
91
- result["availability"]=page.search("#fk-stock-info-id").text()
92
- result["description"]=page.search("#description").inner_html().force_encoding("UTF-8")
81
+ result["price"] = price
82
+ result["availability"] = page.search("#fk-stock-info-id").text()
83
+ result["description"] = page.search("#description").inner_html().force_encoding("UTF-8")
93
84
  result["description"].gsub!('<a href="#">top</a>',"")
94
85
  result
95
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: book_finder_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2013-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri