qunar 0.0.29 → 0.0.32

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: 41fc2c2ce8c2db8d7ee3a398c5c0fba4b651fe37
4
- data.tar.gz: e5245046be9da4bb594afad1849f1d09cd34a556
3
+ metadata.gz: 89b8b2cf234cc5fedd22d76f0ded9fafd1e77cef
4
+ data.tar.gz: d6513eb1642959ce237917743723bdcc09e6da87
5
5
  SHA512:
6
- metadata.gz: 896dcad67755096348af57505ca6bb6660b4cffcb1b9124ccf15983cb36672e5b8148d88a267d6b962ac106c0fca2093c083a390976d0a4895f35d1b9868ed40
7
- data.tar.gz: 7969b139f946154408966153af37dbd4cc097c2299c93fe3e7d5e390da750e97328ceff2514d24b6b2653277d18c4cee92cd1a1c10c6cc7e59b0e6afe3f1b8ad
6
+ metadata.gz: 8c6c84123c0e521edbe618f8906647f868221ec1e631222809dbdee38419be990161111d7022199b2c1970c756dd416ec9c76e8d57353d81590a647f93a54e13
7
+ data.tar.gz: bbaaad66c2e3dfc81ee423864d903ed104360f3463d9c8c6915234d8d3953678c88e08b7a99d50b5b35a619d4e23fd8ac9dfd1ce0cc820072adaa52e783b43a7
data/lib/qunar/rank.rb CHANGED
@@ -14,50 +14,50 @@ module Qunar
14
14
  Capybara.current_driver = :poltergeist #selenium / webkit
15
15
  Capybara.default_selector = :xpath
16
16
  Capybara.app_host = 'http://hotel.qunar.com'
17
- page.driver.headers = { "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" }
17
+ page.driver.headers = { "User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.77.4 (KHTML, like Gecko) Version/7.0.5 Safari/537.77.4" }
18
18
  @HotelSEQ = hotelId #hotelId is "cityurl_hotelcode"
19
19
  @cityurl = hotelId[0..hotelId.rindex("_",-1)-1]
20
20
  @hotelcode = hotelId[hotelId.rindex("_",-1)+1..hotelId.length]
21
21
  @uri = URI(File.join('/city', @cityurl, "dt-#{@hotelcode}"))
22
22
  visit @uri
23
- puts 'cp 2'
24
- sleep 30
23
+ traffic_size = 0
24
+ maximum = 0
25
+ loop do
26
+ sleep 3
27
+ traffic_size = page.driver.network_traffic.size
28
+ puts "Get dynamic request #{traffic_size}"
29
+ break if traffic_size == maximum
30
+ maximum = traffic_size if maximum < traffic_size
31
+ end
25
32
  # k = 0
26
33
  all('//td[@class="book-ct"]//*[text()="展开报价"] | //td[@class="book-ct"]//*[text()="全部订完"]').each do |spage|
27
34
  puts 'cp 2-1'
28
- # k += 1
29
- # filePath = 'test' + k.to_s + '.html'
30
- # File.open('test.html','w') do |file|
31
- # file.puts page.html
32
- # end
33
35
  spage.trigger('click')
34
- sleep 1
35
36
  puts 'cp 2-2'
36
37
  end
37
38
  puts 'cp 3'
38
39
  #@page = Capybara.current_session.driver.browser.page_source #use when choose capybara driver selenium
39
40
  @page = Capybara.current_session.driver.browser.body #use when choose capybara driver webkit
40
- puts 'cp 4'
41
41
  @hotel = Nokogiri::HTML @page
42
42
 
43
43
  end
44
44
 
45
45
  def rooms
46
46
  rooms = []
47
+
47
48
  # room
48
- puts 'cp 5'
49
- @hotel.search("//ul[@class='htl-type-list clrfix']/li").each do |li|
49
+ @hotel.search("//li[@class='default-type defaultpricetype similar-expand']").each do |li|
50
50
  #puts 'one roomtype found'
51
51
  room = {}
52
- type = li.search("span[@class='type-name']").first.text.strip
52
+ type = li.search("span[@class='type-name js-p-name']").first.text.strip
53
53
  room['room_type'] = type
54
54
  room['otas'] = []
55
55
  # ota
56
-
57
56
  li.search("div[@class='similar-type-agent-list']/div/div").each do |row|
58
57
  otas = {}
59
58
 
60
- ota = row.search("div[@class='profile-tit']").first.text.strip
59
+ ota = row.search("div[@class='profile-tit']").first
60
+ ota = ota.text.strip
61
61
  otas['ota'] = ota
62
62
 
63
63
  bookable = row.search("a[@class='btn-book']/span")
@@ -121,9 +121,8 @@ module Qunar
121
121
  rooms << room
122
122
 
123
123
  end
124
- puts 'cp 6'
125
124
  return rooms
126
125
  end
127
126
 
128
127
  end
129
- end
128
+ end
data/lib/qunar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qunar
2
- VERSION = "0.0.29"
2
+ VERSION = "0.0.32"
3
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.29
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - JusticeChow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler