daodao 0.1.7 → 0.1.9

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: 063d365c48571b42e3e614d83495bceeb5a1c6b6
4
- data.tar.gz: e45c6b2ee49468d44e6a0717cfabe2c92a7782c0
3
+ metadata.gz: 829ac44e5532de0924ba017e842028d8f66a32a5
4
+ data.tar.gz: 9385b26192212932f45f72a15358e8ae98b59acc
5
5
  SHA512:
6
- metadata.gz: 4a4838b8a4c674557f0e88ee1d84165ecc33f7766030eb449d93492667ac7ecf68f8a81c0fc5e8197f9bb81dffa0800f77ed08a3fcc4d73cb033a4de7a13a589
7
- data.tar.gz: 372ddb0caa106c0a06b241c3b24fa9e0011315bc67488416c8e5f92e38c25a8faaa1dfc9c2b59da3963512fe7e68504b619bf42e5cdaeb7f3bfdc424e241f377
6
+ metadata.gz: bcbf92a61f84e9e2481b3de18a9499b015d74cfc8123e04325c6939ce66c3079a64821de350429c8c4abd3be396e2bbcc4afb785ea3f71e1a06f75f93371ef83
7
+ data.tar.gz: dbe243cb09066356059b2d16f5901df036afb6e596db80005c469842228b35fcc5a63ac1c61b73e540acd90f1a0151b87b9819c9e55d88f553888b1bb7cffb2e
@@ -1,11 +1,6 @@
1
- require 'nokogiri'
2
- require 'capybara'
3
- require 'capybara-webkit'
4
- require 'open-uri'
5
- require 'daodao/version'
6
- require 'daodao/rank'
7
- require 'daodao/hotel'
8
- require 'daodao/hotel_list'
1
+ %W(nokogiri capybara capybara-webkit open-uri httparty daodao/version daodao/rank daodao/hotel daodao/hotel_list daodao/rank_fast).each do |file|
2
+ require file
3
+ end
9
4
  module Daodao
10
5
  def self.rank(hotel_id)
11
6
  url = "http://www.daodao.com/Hotel_Review/d#{hotel_id}"
@@ -0,0 +1,54 @@
1
+ module Daodao
2
+ class RankFast
3
+ Host = 'www.daodao.com'
4
+ headers = {
5
+ "User-Agent" => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.73.11 (KHTML, like Gecko) Version/7.0.1 Safari/537.73.11'
6
+ }
7
+ Options = { :headers => headers }
8
+
9
+ def initialize
10
+ @date = Date.today
11
+ @inMonth = "#{@date.month}/#{@date.year}"
12
+ @outMonth = @inMonth
13
+ @inDay = @date.day
14
+ @outDay = @inDay + 1
15
+ @params = {
16
+ :inMonth => @inMonth,
17
+ :inDay => @inDay,
18
+ :outMonth => @outMonth,
19
+ :outDay => @outDay,
20
+ :area => 'QC_Meta_Mini',
21
+ :adults => 2,
22
+ :returnAllOffers => true
23
+ }
24
+ end
25
+
26
+ def rank(hotel_id)
27
+ hotel_id = hotel_id[/\d+/]
28
+ q = Array.new
29
+ q << "detail=#{hotel_id}"
30
+ # Join arguments
31
+ @params.each do |k, v|
32
+ q << "#{k.to_s}=#{v.to_s}"
33
+ end
34
+ uri = URI::HTTP.build(:host=>Host,:path=>'/MiniMetaCRAjax',:query=>q.join('&'))
35
+ @html = Nokogiri::HTML(HTTParty.get(uri, Options))
36
+ row = {}
37
+ row[:hotel_id] = hotel_id
38
+ provider = @html.css("*.no_cpu.offer")
39
+ rank = 1
40
+ #row[:hotel_name] = @html.search("//h1[@id='HEADING']/text()").to_s.gsub(/\n|\s/,'')
41
+ provider.each { |item|
42
+ key = 'rank'+rank.to_s
43
+ row[key.to_sym] = item['data-vendorname']
44
+ rank+=1
45
+ }
46
+ row
47
+ end
48
+
49
+ def html
50
+ @html.to_html
51
+ end
52
+
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Daodao
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daodao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - timlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - lib/daodao/hotel.rb
71
71
  - lib/daodao/hotel_list.rb
72
72
  - lib/daodao/rank.rb
73
+ - lib/daodao/rank_fast.rb
73
74
  - lib/daodao/version.rb
74
75
  - spec/hotel_list_spec.rb
75
76
  - spec/hotel_spec.rb