Class: ESpider::Front::Qunar::Base
- Inherits:
-
Object
- Object
- ESpider::Front::Qunar::Base
- Defined in:
- lib/espider/front/qunar/base.rb
Constant Summary collapse
- BASEURI =
"http://hotel.qunar.com"
Instance Method Summary collapse
-
#initialize(hotelId) ⇒ Base
constructor
A new instance of Base.
- #parse_mixkey ⇒ Object
Constructor Details
#initialize(hotelId) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 |
# File 'lib/espider/front/qunar/base.rb', line 8 def initialize(hotelId) raise "id should be string" if !hotelId.instance_of?(String) @HotelSEQ = hotelId @cityurl = hotelId[0..hotelId.rindex("_",-1)-1] @hotelcode = hotelId[hotelId.rindex("_",-1)+1..hotelId.length] end |
Instance Method Details
#parse_mixkey ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/espider/front/qunar/base.rb', line 14 def parse_mixkey uri = URI(File.join(BASEURI, 'city', @cityurl, "dt-#{@hotelcode}")) http_res = HTTParty.get uri.to_s res = Nokogiri::HTML http_res node = res.search('//span[@id="eyKxim"]').first return nil if node.nil? return node.text end |