-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.rb
74 lines (61 loc) · 2.29 KB
/
Room.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'active_record'
require 'mysql2'
require "mechanize"
require "nokogiri"
require "open-uri"
require "json"
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:host => "121.88.250.82",
:database => "scrap",
:username => "zipbac",
:password => "relifer2015"
)
ActiveRecord::Base.default_timezone = :local
class List < ActiveRecord::Base
end
class Room
def initialize
# @room_list = List.all
@mechanize =
Mechanize.new {|a| a.ssl_version, a.verify_mode ='TLSv1',OpenSSL::SSL::VERIFY_NONE}
@mechanize.user_agent_alias = 'Mac Safari'
@room_info_api_url = {
zigbang: {
doksan: 'https://api.zigbang.com/v2/items?lat_south=37.45335518537516&lat_north=37.482942299091896&lng_west=126.87943097477127&lng_east=126.91931760306952&room=01;02;03;04;05&deposit_s=5000&deposit_e=7000&rent_s=0&rent_e=0',
gasan: 'https://api.zigbang.com/v2/items?lat_south=37.462068825971514&lat_north=37.49165851263533&lng_west=126.87168556873984&lng_east=126.9115737608987&room=01;02;03;04;05&deposit_s=5000&deposit_e=7000&rent_s=0&rent_e=0'
},
dabang: {
doksan: '',
gasan: ''
}
}
@room_list_api_url = {
zigbang: {
doksan: 'https://api.zigbang.com/v2/items?lat_south=37.45335518537516&lat_north=37.482942299091896&lng_west=126.87943097477127&lng_east=126.91931760306952&room=01;02;03;04;05&deposit_s=5000&deposit_e=7000&rent_s=0&rent_e=0',
gasan: 'https://api.zigbang.com/v2/items?lat_south=37.462068825971514&lat_north=37.49165851263533&lng_west=126.87168556873984&lng_east=126.9115737608987&room=01;02;03;04;05&deposit_s=5000&deposit_e=7000&rent_s=0&rent_e=0'
},
dabang: {
doksan: '',
gasan: ''
}
}
end
def get_room_list
#방리스트 가져옴
list = @mechanize.get(@room_info_api_url[:zigbang][:doksan]).body
end
def update_room_list
#방 리스트 db에 업데이트 시킴
end
def generate_zigbang_url()
#api서버에서 받은 방 id로 request보낼 api서버 주소 생성
end
def generate_dabang_url()
#api서버에서 받은 방 id로 request보낼 api서버 주소 생성
end
end
test = Room.new()
list = test.get_room_list
result = JSON.parse list
pp result['list_items'][1]