qunar 0.0.9 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5604f862bc0dd6e981ca8f56a044ca4c3e67f3db
4
- data.tar.gz: 8143750a2056c1bfe622a40db4e598ad62f6e00d
3
+ metadata.gz: f543b7cfd2899611382f428ac228f39b8773158b
4
+ data.tar.gz: 9ba5b1db1ba8622179dd9f0f38100775fac55a58
5
5
  SHA512:
6
- metadata.gz: b9531537c87695b3c1c2728ee835d4e2155d111f0b5228660bb07fefdeb3a8a720202e65bbb7f6712f59dcdf9d35fcf8fd1d1f35963193f8616667dfa0e56971
7
- data.tar.gz: ca4acfbcdbb3ae3d36ee9cb304462a6825ab2604fc12018c3859c310ab68ca3aaafd8041e3cb92ce55ce1fc28098c61a5f37955a726eb1e58aa08f020e6c8f48
6
+ metadata.gz: ef8a0aee6619db34359d1bcc74b6344f5ae32b9a2e3fdda40734c761fa70fcbde07400575c8750702138ad9aa6efe97dde73f19dfbbba5c5be89fa18e2d7f057
7
+ data.tar.gz: 70604a8071ba35ae920359b2a38e63fe149d34a0fee439b72b01829394753825e70b14f8e1b386ccb0d830446c879c00ee565c6ee40b56abb62f1feaa68b3cd6
data/lib/qunar/rank.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'capybara'
2
2
  require 'nokogiri'
3
3
  require 'capybara-webkit'
4
+ #require 'selenium-webdriver'
4
5
 
5
- Capybara.current_driver = :webkit
6
+ Capybara.current_driver = :webkit #selenium / webkit
6
7
  Capybara.default_selector = :xpath
7
8
  Capybara.app_host = 'http://hotel.qunar.com'
9
+ #Capybara.page.driver.header('user-agent','Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50')
8
10
 
9
11
 
10
12
  module Qunar
@@ -12,27 +14,36 @@ module Qunar
12
14
  include Capybara::DSL
13
15
 
14
16
  def initialize(hotelId)
17
+ puts 'cp 0'
15
18
  raise "id should be string" if !hotelId.instance_of?(String)
19
+ puts 'cp 1'
16
20
  @HotelSEQ = hotelId #hotelId is "cityurl_hotelcode"
17
21
  @cityurl = hotelId[0..hotelId.rindex("_",-1)-1]
18
22
  @hotelcode = hotelId[hotelId.rindex("_",-1)+1..hotelId.length]
23
+ puts 'cp 1-1'
19
24
  @uri = URI(File.join('/city', @cityurl, "dt-#{@hotelcode}"))
25
+ puts 'cp 1-2'
20
26
  visit @uri
21
- all('//*[text()="展开报价"]').each do |btn|
22
- btn.click
23
- end
24
- all('//*[text()="全部订完"]').each do |btn|
27
+ puts 'cp 2'
28
+ all('//td[@class="book-ct"]//*[text()="展开报价"] | //td[@class="book-ct"]//*[text()="全部订完"]').each do |btn|
29
+ puts 'cp 2-1'
25
30
  btn.click
31
+ puts 'cp 2-2'
26
32
  end
33
+ puts 'cp 3'
27
34
  #@page = Capybara.current_session.driver.browser.page_source #use when choose capybara driver selenium
28
35
  @page = Capybara.current_session.driver.browser.body #use when choose capybara driver webkit
36
+ puts 'cp 4'
29
37
  @hotel = Nokogiri::HTML @page
38
+
30
39
  end
31
40
 
32
41
  def rooms
33
42
  rooms = []
34
43
  # room
44
+ puts 'cp 5'
35
45
  @hotel.search("//ul[@class='htl-type-list clrfix']/li").each do |li|
46
+ puts 'one roomtype found'
36
47
  room = {}
37
48
  type = li.search("span[@class='type-name']").first.text.strip
38
49
  room['room_type'] = type
@@ -96,11 +107,11 @@ module Qunar
96
107
  room['otas'] << otas
97
108
  end
98
109
  rooms << room
99
-
110
+
100
111
  end
112
+ puts 'cp 6'
101
113
  return rooms
102
114
  end
103
115
 
104
-
105
116
  end
106
117
  end
data/lib/qunar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qunar
2
- VERSION = "0.0.9"
3
- end
2
+ VERSION = "0.0.13"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qunar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - JusticeChow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler