Class: ESpider::Front::Qunar::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/espider/front/qunar/base.rb

Direct Known Subclasses

Hotel, Rank

Constant Summary collapse

BASEURI =
"http://hotel.qunar.com"

Instance Method Summary collapse

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_mixkeyObject



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