qunar 0.0.13 → 0.0.27

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: f543b7cfd2899611382f428ac228f39b8773158b
4
- data.tar.gz: 9ba5b1db1ba8622179dd9f0f38100775fac55a58
3
+ metadata.gz: fe6a1e6d072c39608b9c60fb1780c161529cd077
4
+ data.tar.gz: dbbaffcb34e7191c859d9032c788bd5cb2c74c5f
5
5
  SHA512:
6
- metadata.gz: ef8a0aee6619db34359d1bcc74b6344f5ae32b9a2e3fdda40734c761fa70fcbde07400575c8750702138ad9aa6efe97dde73f19dfbbba5c5be89fa18e2d7f057
7
- data.tar.gz: 70604a8071ba35ae920359b2a38e63fe149d34a0fee439b72b01829394753825e70b14f8e1b386ccb0d830446c879c00ee565c6ee40b56abb62f1feaa68b3cd6
6
+ metadata.gz: ef8d632b88ec10f5749efc4c96e8afd8682f236f272f9425cdf2a4a7d30c26f59403a1a3055f52b11973297ab8f294b1c33df788de434e7c626145b76285baae
7
+ data.tar.gz: 0aee015e9f22ff5fea9dc2d80e18e3a5fb8e43f58d32e5ef944307f21aed5ce337c36430d7177193ac8fa931e1f4c6508ea8417e0b7fde0dd58637ca8e5be11a
data/lib/qunar/rank.rb CHANGED
@@ -1,33 +1,37 @@
1
1
  require 'capybara'
2
2
  require 'nokogiri'
3
- require 'capybara-webkit'
3
+ require 'capybara/poltergeist'
4
+ #require 'capybara-webkit'
4
5
  #require 'selenium-webdriver'
5
6
 
6
- Capybara.current_driver = :webkit #selenium / webkit
7
- Capybara.default_selector = :xpath
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')
10
-
11
-
12
7
  module Qunar
13
8
  class Rank
14
9
  include Capybara::DSL
15
10
 
16
11
  def initialize(hotelId)
17
- puts 'cp 0'
12
+
18
13
  raise "id should be string" if !hotelId.instance_of?(String)
19
- puts 'cp 1'
14
+ Capybara.current_driver = :poltergeist #selenium / webkit
15
+ Capybara.default_selector = :xpath
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" }
20
18
  @HotelSEQ = hotelId #hotelId is "cityurl_hotelcode"
21
19
  @cityurl = hotelId[0..hotelId.rindex("_",-1)-1]
22
20
  @hotelcode = hotelId[hotelId.rindex("_",-1)+1..hotelId.length]
23
- puts 'cp 1-1'
24
21
  @uri = URI(File.join('/city', @cityurl, "dt-#{@hotelcode}"))
25
- puts 'cp 1-2'
26
22
  visit @uri
27
23
  puts 'cp 2'
28
- all('//td[@class="book-ct"]//*[text()="展开报价"] | //td[@class="book-ct"]//*[text()="全部订完"]').each do |btn|
24
+ sleep 30
25
+ # k = 0
26
+ all('//td[@class="book-ct"]//*[text()="展开报价"] | //td[@class="book-ct"]//*[text()="全部订完"]').each do |spage|
29
27
  puts 'cp 2-1'
30
- btn.click
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
+ spage.trigger('click')
34
+ sleep 1
31
35
  puts 'cp 2-2'
32
36
  end
33
37
  puts 'cp 3'
@@ -43,7 +47,7 @@ module Qunar
43
47
  # room
44
48
  puts 'cp 5'
45
49
  @hotel.search("//ul[@class='htl-type-list clrfix']/li").each do |li|
46
- puts 'one roomtype found'
50
+ #puts 'one roomtype found'
47
51
  room = {}
48
52
  type = li.search("span[@class='type-name']").first.text.strip
49
53
  room['room_type'] = type
data/lib/qunar/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qunar
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.27"
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.13
4
+ version: 0.0.27
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-01 00:00:00.000000000 Z
11
+ date: 2014-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler