weget 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/weget/.DS_Store +0 -0
- data/lib/weget/analysis.rb +80 -0
- data/lib/weget/cert.pem +4711 -0
- data/lib/weget/config.rb +28 -0
- data/lib/weget/crawler.rb +168 -0
- data/lib/weget/lib.rb +57 -0
- data/lib/weget/version.rb +1 -1
- metadata +9 -1
data/lib/weget/config.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
USER_ID = "xxxxxx"
|
|
4
|
+
USER_PASS = "xxxxxx"
|
|
5
|
+
|
|
6
|
+
URL_SERVICE = 'https://www.iauc.co.jp/service/'
|
|
7
|
+
URL_TAB_CREATE = 'https://www.iauc.co.jp/ajax/tab/create'
|
|
8
|
+
URL_NOTICE_PRE_LOGIN = 'https://www.iauc.co.jp/ajax/service/notice_pre_login'
|
|
9
|
+
URL_REQUIRED_NOTICE = 'https://www.iauc.co.jp/ajax/service/required_notice'
|
|
10
|
+
URL_REQUIRED_NOTICE_TOP = 'https://www.iauc.co.jp/ajax/service/required_notice_top'
|
|
11
|
+
URL_LOGIN = 'https://www.iauc.co.jp/service/login'
|
|
12
|
+
URL_MARKET = 'https://www.iauc.co.jp/market/'
|
|
13
|
+
URL_LOGOUT = 'https://www.iauc.co.jp/service/logout'
|
|
14
|
+
|
|
15
|
+
URL_TAB_CHANGE = 'https://www.iauc.co.jp/ajax/tab/change'
|
|
16
|
+
URL_SEARCH_MARKET = 'https://www.iauc.co.jp/ajax/search/makers?vehicleType=car&mode=market&siteId=25%2C12%2C14%2C13%2C15%2C11%2C10%2C65%2C231%2C2%2C4%2C1%2C20%2C22%2C23%2C21%2C163%2C28%2C253%2C62%2C63%2C68%2C71%2C80%2C51%2C58%2C117%2C93%2C250%2C142%2C148%2C139%2C146%2C147%2C192%2C193%2C211%2C216%2C219%2C197%2C198%2C217%2C212%2C3%2C89%2C165%2C40%2C91%2C43%2C114%2C111%2C252%2C224%2C7%2C90%2C59%2C57%2C84%2C52%2C81%2C140%2C194%2C18%2C19%2C16%2C143%2C39%2C42%2C6%2C29%2C35%2C37%2C70%2C79%2C54%2C61%2C60%2C67%2C87%2C95%2C88%2C119%2C251%2C196%2C195%2C240%2C241%2C242%2C86%2C55%2C64%2C53%2C66%2C82%2C48%2C221%2C222%2C223%2C30%2C73%2C33%2C41%2C113%2C237%2C238%2C239%2C243%2C5%2C74%2C78%2C56%2C206%2C31%2C235%2C17%2C34%2C36%2C38&_=1524808327595'
|
|
17
|
+
URL_SEARCH_MARKET2 = 'https://www.iauc.co.jp/market/search?d=25%2C12%2C14%2C13%2C15%2C11%2C10%2C65%2C231%2C2%2C4%2C1%2C20%2C22%2C23%2C21%2C163%2C28%2C253%2C62%2C63%2C68%2C71%2C80%2C51%2C58%2C117%2C93%2C250%2C142%2C148%2C139%2C146%2C147%2C192%2C193%2C211%2C216%2C219%2C197%2C198%2C217%2C212%2C3%2C89%2C165%2C40%2C91%2C43%2C114%2C111%2C252%2C224%2C7%2C90%2C59%2C57%2C84%2C52%2C81%2C140%2C194%2C18%2C19%2C16%2C143%2C39%2C42%2C6%2C29%2C35%2C37%2C70%2C79%2C54%2C61%2C60%2C67%2C87%2C95%2C88%2C119%2C251%2C196%2C195%2C240%2C241%2C242%2C86%2C55%2C64%2C53%2C66%2C82%2C48%2C221%2C222%2C223%2C30%2C73%2C33%2C41%2C113%2C237%2C238%2C239%2C243%2C5%2C74%2C78%2C56%2C206%2C31%2C235%2C17%2C34%2C36%2C38&referer_site=true'
|
|
18
|
+
URL_SEARCH_VEHICLE = 'https://www.iauc.co.jp/ajax/search/vehicle_names?vehicleType=car&makerId=8&siteId=25%2C12%2C14%2C13%2C15%2C11%2C10%2C65%2C231%2C2%2C4%2C1%2C20%2C22%2C23%2C21%2C163%2C28%2C253%2C62%2C63%2C68%2C71%2C80%2C51%2C58%2C117%2C93%2C250%2C142%2C148%2C139%2C146%2C147%2C192%2C193%2C211%2C216%2C219%2C197%2C198%2C217%2C212%2C3%2C89%2C165%2C40%2C91%2C43%2C114%2C111%2C252%2C224%2C7%2C90%2C59%2C57%2C84%2C52%2C81%2C140%2C194%2C18%2C19%2C16%2C143%2C39%2C42%2C6%2C29%2C35%2C37%2C70%2C79%2C54%2C61%2C60%2C67%2C87%2C95%2C88%2C119%2C251%2C196%2C195%2C240%2C241%2C242%2C86%2C55%2C64%2C53%2C66%2C82%2C48%2C221%2C222%2C223%2C30%2C73%2C33%2C41%2C113%2C237%2C238%2C239%2C243%2C5%2C74%2C78%2C56%2C206%2C31%2C235%2C17%2C34%2C36%2C38&mode=market&_=1524808327596'
|
|
19
|
+
URL_SEARCH_GRADES = 'https://www.iauc.co.jp/ajax/search/grades?makerVehicleId%5B%5D=8-%EF%BD%B4%EF%BE%99%EF%BE%8C&siteId=25%2C12%2C14%2C13%2C15%2C11%2C10%2C65%2C231%2C2%2C4%2C1%2C20%2C22%2C23%2C21%2C163%2C28%2C253%2C62%2C63%2C68%2C71%2C80%2C51%2C58%2C117%2C93%2C250%2C142%2C148%2C139%2C146%2C147%2C192%2C193%2C211%2C216%2C219%2C197%2C198%2C217%2C212%2C3%2C89%2C165%2C40%2C91%2C43%2C114%2C111%2C252%2C224%2C7%2C90%2C59%2C57%2C84%2C52%2C81%2C140%2C194%2C18%2C19%2C16%2C143%2C39%2C42%2C6%2C29%2C35%2C37%2C70%2C79%2C54%2C61%2C60%2C67%2C87%2C95%2C88%2C119%2C251%2C196%2C195%2C240%2C241%2C242%2C86%2C55%2C64%2C53%2C66%2C82%2C48%2C221%2C222%2C223%2C30%2C73%2C33%2C41%2C113%2C237%2C238%2C239%2C243%2C5%2C74%2C78%2C56%2C206%2C31%2C235%2C17%2C34%2C36%2C38&ep=%2FmarketPrice%2FcarNames%2Ftypes%2Fgrades&_=1524808327598'
|
|
20
|
+
URL_SEARCH_TYPES = 'https://www.iauc.co.jp/ajax/search/types?makerVehicleId%5B%5D=8-%EF%BD%B4%EF%BE%99%EF%BE%8C&siteId=25%2C12%2C14%2C13%2C15%2C11%2C10%2C65%2C231%2C2%2C4%2C1%2C20%2C22%2C23%2C21%2C163%2C28%2C253%2C62%2C63%2C68%2C71%2C80%2C51%2C58%2C117%2C93%2C250%2C142%2C148%2C139%2C146%2C147%2C192%2C193%2C211%2C216%2C219%2C197%2C198%2C217%2C212%2C3%2C89%2C165%2C40%2C91%2C43%2C114%2C111%2C252%2C224%2C7%2C90%2C59%2C57%2C84%2C52%2C81%2C140%2C194%2C18%2C19%2C16%2C143%2C39%2C42%2C6%2C29%2C35%2C37%2C70%2C79%2C54%2C61%2C60%2C67%2C87%2C95%2C88%2C119%2C251%2C196%2C195%2C240%2C241%2C242%2C86%2C55%2C64%2C53%2C66%2C82%2C48%2C221%2C222%2C223%2C30%2C73%2C33%2C41%2C113%2C237%2C238%2C239%2C243%2C5%2C74%2C78%2C56%2C206%2C31%2C235%2C17%2C34%2C36%2C38&ep=%2FmarketPrice%2FcarNames%2Ftypes&_=1524808327597'
|
|
21
|
+
|
|
22
|
+
URL_CARLIST = 'https://www.iauc.co.jp/market/carlist'
|
|
23
|
+
URL_CARLIST_NARROW = 'https://www.iauc.co.jp/ajax/list/carlist_narrow'
|
|
24
|
+
URL_CARLIST_NEXTPAGE = 'https://www.iauc.co.jp/ajax/list/carlist?element=&sort_type=&limit=100&branch=&controller=marketvehicle&display_mode=&page_myListId=&page_requestId=&type=page&isHtml=true&preload=0&mode=table&referrer='
|
|
25
|
+
|
|
26
|
+
COOKIE_CARLIST = 'iauc_lang=ja; _ga=GA1.3.1960749188.1524724940; _gid=GA1.3.162237504.1524724940; iauc_rf=0; iauc_limit_vehicle=15; iauc_limit_market_vehicle=100; iauc_search_period_vehicle=12; _gat=1;'
|
|
27
|
+
QUERY_CARLIST = 'boxMakerScroll=0&domesticMakerScroll=106&foreignMakerScroll=200&boxTypeScroll=0&boxModelScroll=0&boxGradeScroll=0&attrColorScroll=0&makerAccordionButtonOpen=0&nameAccordionButtonOpen=0&maker%5B%5D=8&type%5B%5D=8-%7B%EF%BD%B4%EF%BE%99%EF%BE%8C%7D&searchPeriod=12&modelOfYearFrom=&modelOfYearTo=&mileageFrom=&mileageTo=&rateFrom=&rateTo=&vehicleInspection=&shiftType=&search_mode=maker'
|
|
28
|
+
QUERY_CARLIST_2 = 'boxMakerScroll=0&domesticMakerScroll=0&foreignMakerScroll=0&boxTypeScroll=3735&boxModelScroll=0&boxGradeScroll=0&attrColorScroll=0&makerAccordionButtonOpen=0&nameAccordionButtonOpen=0&__tid=941d6bba79e0970136cdc8c45af4407818618&maker%5B%5D=0&type%5B%5D=0-%7B%EF%BE%80%EF%BE%9E%EF%BD%B2%EF%BE%85%7D&searchPeriod=12&modelOfYearFrom=&modelOfYearTo=&mileageFrom=&mileageTo=&rateFrom=&rateTo=&vehicleInspection=&shiftType=&search_mode=maker'
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'json'
|
|
5
|
+
require './lib.rb'
|
|
6
|
+
require './config.rb'
|
|
7
|
+
|
|
8
|
+
ENV['SSL_CERT_FILE'] = File.join(File.dirname($0), 'cert.pem')
|
|
9
|
+
exit if Object.const_defined?(:Ocra)
|
|
10
|
+
#1 セットVist
|
|
11
|
+
puts "1 セットVist #{URL_SERVICE}"
|
|
12
|
+
res = get(URL_SERVICE, nil)
|
|
13
|
+
setCookie = res.header["set-cookie"].to_s
|
|
14
|
+
cookies = setCookie.split(";")
|
|
15
|
+
stmp = find_cookie(cookies, " path=/, _l_tm_stmp=")
|
|
16
|
+
fuelrid = find_cookie(cookies, " path=/, fuelrid=")
|
|
17
|
+
awselb = find_cookie(cookies, " path=/, AWSELB=")
|
|
18
|
+
|
|
19
|
+
cookie = "iauc_lang=ja; _l_tm_stmp=#{stmp}; fuelrid=#{fuelrid}; AWSELB=#{awselb}"
|
|
20
|
+
puts "1 セットVist cookie => #{cookie}"
|
|
21
|
+
puts "======================================"
|
|
22
|
+
|
|
23
|
+
#2 新規TID
|
|
24
|
+
# puts "2 新規TID #{URL_TAB_CREATE}"
|
|
25
|
+
# tab_id = ""
|
|
26
|
+
# res = post(URL_TAB_CREATE, cookie, "old_tab_id=#{tab_id}&has_focus=true", nil)
|
|
27
|
+
# fileName = "./out/tid.html"
|
|
28
|
+
# File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
29
|
+
# exit
|
|
30
|
+
# xml = Nokogiri::XML(res.body)
|
|
31
|
+
# tab_id = xml.xpath("//tab_id")[0].text
|
|
32
|
+
xml = Nokogiri::HTML(res.body)
|
|
33
|
+
tab_id = xml.xpath('//*[@id="slider"]/div[5]/a')[0]["href"]
|
|
34
|
+
tab_id = tab_id.split('?__tid=')[1]
|
|
35
|
+
puts "2 新規TID tid => #{tab_id}"
|
|
36
|
+
puts "======================================"
|
|
37
|
+
|
|
38
|
+
#3 仮ログイン
|
|
39
|
+
puts "3 仮ログイン #{URL_NOTICE_PRE_LOGIN}"
|
|
40
|
+
data = "id=#{USER_ID}&password=#{USER_PASS}&referer=normal"
|
|
41
|
+
res = post(URL_NOTICE_PRE_LOGIN, cookie, data, nil)
|
|
42
|
+
xml = Nokogiri::XML(res.body)
|
|
43
|
+
item = xml.xpath("//item")[0].text
|
|
44
|
+
puts "3 仮ログイン item => #{item}"
|
|
45
|
+
puts "======================================"
|
|
46
|
+
|
|
47
|
+
#4 お知らせ
|
|
48
|
+
puts "4 お知らせ1 #{URL_REQUIRED_NOTICE}"
|
|
49
|
+
res = get("#{URL_REQUIRED_NOTICE}?id=#{item}&_=15247339838444", cookie)
|
|
50
|
+
puts "======================================"
|
|
51
|
+
|
|
52
|
+
#5 お知らせ
|
|
53
|
+
puts "5 お知らせ2 #{URL_REQUIRED_NOTICE_TOP}"
|
|
54
|
+
res = get("#{URL_REQUIRED_NOTICE_TOP}?id=#{item}&_=1524733983845", cookie)
|
|
55
|
+
puts "======================================"
|
|
56
|
+
|
|
57
|
+
#6 ログイン
|
|
58
|
+
puts "6 ログイン #{URL_LOGIN}"
|
|
59
|
+
data = "id=#{USER_ID}&password=#{USER_PASS}&__tid=#{tab_id}"
|
|
60
|
+
res = post(URL_LOGIN, cookie, data, "#{URL_LOGIN}?__tid=#{tab_id}")
|
|
61
|
+
puts "======================================"
|
|
62
|
+
|
|
63
|
+
begin
|
|
64
|
+
#相場検索⇒全選択⇒次へ=>イスズ⇒エルフ⇒次へ=>次ページ .... =>lastページ
|
|
65
|
+
now = Time.now.to_i.to_s
|
|
66
|
+
#7.1 ページVist 相場会場選択
|
|
67
|
+
puts "7.1 ページVist 相場会場選択 #{URL_MARKET}"
|
|
68
|
+
url = "#{URL_MARKET}?sess=clear&sess_m=clear?__tid=#{tab_id}"
|
|
69
|
+
res = post(url, cookie, "", "#{URL_LOGIN}?__tid=#{tab_id}")
|
|
70
|
+
fileName = "./out/#{now}.html"
|
|
71
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
72
|
+
puts "7.1 ページVist 相場会場選択 output => #{fileName}"
|
|
73
|
+
puts "======================================"
|
|
74
|
+
|
|
75
|
+
#7.2 相場会場検索
|
|
76
|
+
puts "7.2 相場会場検索 #{URL_SEARCH_MARKET}"
|
|
77
|
+
res = get("#{URL_SEARCH_MARKET}&__tid=#{tab_id}", cookie)
|
|
78
|
+
fileName = "./out/#{now}_maker.json"
|
|
79
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
80
|
+
puts "7.2 相場会場検索 output => #{fileName}"
|
|
81
|
+
puts "======================================"
|
|
82
|
+
|
|
83
|
+
#7.3 相場会場検索2
|
|
84
|
+
puts "7.3 相場会場検索2 #{URL_SEARCH_MARKET2}"
|
|
85
|
+
res = get("#{URL_SEARCH_MARKET2}&__tid=#{tab_id}", cookie)
|
|
86
|
+
fileName = "./out/#{now}_maker.html"
|
|
87
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
88
|
+
puts "7.3 相場会場検索2 output => #{fileName}"
|
|
89
|
+
puts "======================================"
|
|
90
|
+
|
|
91
|
+
#7.4 車両検索
|
|
92
|
+
puts "7.4 車両検索 #{URL_SEARCH_VEHICLE}"
|
|
93
|
+
res = get("#{URL_SEARCH_VEHICLE}&__tid=#{tab_id}", cookie)
|
|
94
|
+
fileName = "./out/#{now}_vehicle.json"
|
|
95
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
96
|
+
puts "7.4 車両検索 output => #{fileName}"
|
|
97
|
+
puts "======================================"
|
|
98
|
+
|
|
99
|
+
#7.5 グレード検索
|
|
100
|
+
puts "7.5 グレード検索 #{URL_SEARCH_GRADES}"
|
|
101
|
+
res = get("#{URL_SEARCH_GRADES}&__tid=#{tab_id}", cookie)
|
|
102
|
+
fileName = "./out/#{now}_grade.json"
|
|
103
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
104
|
+
puts "7.5 グレード検索 output => #{fileName}"
|
|
105
|
+
puts "======================================"
|
|
106
|
+
|
|
107
|
+
#7.6 タイプ検索
|
|
108
|
+
puts "7.6 タイプ検索 #{URL_SEARCH_TYPES}"
|
|
109
|
+
res = get("#{URL_SEARCH_TYPES}&__tid=#{tab_id}", cookie)
|
|
110
|
+
fileName = "./out/#{now}_type.json"
|
|
111
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
112
|
+
puts "7.6 タイプ検索 output => #{fileName}"
|
|
113
|
+
puts "======================================"
|
|
114
|
+
|
|
115
|
+
#7.8 ページcarlist イスズ エルフ page=1
|
|
116
|
+
puts "7.8 ページcarlist イスズ エルフ page=1 #{URL_CARLIST}"
|
|
117
|
+
cookie = "#{COOKIE_CARLIST} fuelrid=#{fuelrid}; AWSELB=#{awselb}; _l_tm_stmp=#{stmp}"
|
|
118
|
+
data = "__tid=#{tab_id}&#{QUERY_CARLIST}"
|
|
119
|
+
res = post(URL_CARLIST, cookie, data, "#{URL_SEARCH_MARKET2}&__tid=#{tab_id}")
|
|
120
|
+
fileName = "./out/#{now}_carlist.html"
|
|
121
|
+
File.open(fileName, 'w') { |file| file.write(res.body) }
|
|
122
|
+
puts "7.8 ページcarlist イスズ エルフ page=1 output => #{fileName}"
|
|
123
|
+
puts "======================================"
|
|
124
|
+
|
|
125
|
+
#7.9 ページcarlist イスズ エルフ page=2
|
|
126
|
+
page = 2
|
|
127
|
+
narrow_key = ""
|
|
128
|
+
data = "element=&narrow_data=&old_narrow_key=#{narrow_key}&__tid=#{tab_id}"
|
|
129
|
+
res = post(URL_CARLIST_NARROW, cookie, data, "#{URL_SEARCH_MARKET2}&__tid=#{tab_id}")
|
|
130
|
+
narrow_data = JSON.parse(res.body)
|
|
131
|
+
narrow_key = narrow_data["narrow_key"]
|
|
132
|
+
puts "7.9 ページcarlist narrow_key => #{narrow_key}"
|
|
133
|
+
puts "7.9 ページcarlist イスズ エルフ page=#{page} #{URL_CARLIST_NEXTPAGE}"
|
|
134
|
+
url = "#{URL_CARLIST_NEXTPAGE}&page=#{page}&narrow_key=#{narrow_key}&__tid=#{tab_id}&_=#{Time.now.to_i.to_s}"
|
|
135
|
+
res = get(url, cookie)
|
|
136
|
+
car_data = JSON.parse(res.body)
|
|
137
|
+
fileName = "./out/#{now}_carlist_page#{page}.html"
|
|
138
|
+
File.open(fileName, 'w') { |file| file.write(car_data["res_html"]) }
|
|
139
|
+
puts "7.9 ページcarlist イスズ エルフ count:#{car_data['count']} page=#{page} output => #{fileName}"
|
|
140
|
+
puts "======================================"
|
|
141
|
+
|
|
142
|
+
pageCnt = (car_data['count'].to_i / 100.00).ceil
|
|
143
|
+
|
|
144
|
+
(3..pageCnt).each do |p|
|
|
145
|
+
#7.9 ページcarlist イスズ エルフ page=3
|
|
146
|
+
page = p
|
|
147
|
+
data = "element=&narrow_data=&old_narrow_key=#{narrow_key}&__tid=#{tab_id}"
|
|
148
|
+
res = post(URL_CARLIST_NARROW, cookie, data, "#{URL_SEARCH_MARKET2}&__tid=#{tab_id}")
|
|
149
|
+
narrow_data = JSON.parse(res.body)
|
|
150
|
+
narrow_key = narrow_data["narrow_key"]
|
|
151
|
+
puts "7.10 ページcarlist narrow_key => #{narrow_key}"
|
|
152
|
+
puts "7.10 ページcarlist イスズ エルフ page=#{page} #{URL_CARLIST_NEXTPAGE}"
|
|
153
|
+
url = "#{URL_CARLIST_NEXTPAGE}&page=#{page}&narrow_key=#{narrow_key}&__tid=#{tab_id}&_=#{Time.now.to_i.to_s}"
|
|
154
|
+
res = get(url, cookie)
|
|
155
|
+
car_data = JSON.parse(res.body)
|
|
156
|
+
fileName = "./out/#{now}_carlist_page#{page}.html"
|
|
157
|
+
File.open(fileName, 'w') { |file| file.write(car_data["res_html"]) }
|
|
158
|
+
puts "7.10 ページcarlist イスズ エルフ count:#{car_data['count']} page=#{page} output => #{fileName}"
|
|
159
|
+
puts "======================================"
|
|
160
|
+
end
|
|
161
|
+
rescue => error
|
|
162
|
+
puts error.message
|
|
163
|
+
ensure
|
|
164
|
+
#10 ログアウト
|
|
165
|
+
puts "99 ログアウト #{URL_LOGOUT}"
|
|
166
|
+
res = get("#{URL_LOGOUT}?__tid=#{tab_id}", cookie)
|
|
167
|
+
puts "======================================"
|
|
168
|
+
end
|
data/lib/weget/lib.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
require 'uri'
|
|
5
|
+
|
|
6
|
+
USER_AGENTE = "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko"
|
|
7
|
+
|
|
8
|
+
def get(uri_str, cookie)
|
|
9
|
+
url = URI.parse(uri_str)
|
|
10
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
11
|
+
http.use_ssl = true
|
|
12
|
+
#http.set_debug_output STDERR
|
|
13
|
+
req = Net::HTTP::Get.new(url.request_uri)
|
|
14
|
+
req["User-Agente"] = USER_AGENTE
|
|
15
|
+
if cookie != nil then
|
|
16
|
+
req["Cookie"] = cookie;
|
|
17
|
+
end
|
|
18
|
+
res = http.request(req)
|
|
19
|
+
case res
|
|
20
|
+
when Net::HTTPSuccess then res
|
|
21
|
+
when Net::HTTPRedirection then res
|
|
22
|
+
else
|
|
23
|
+
res.error!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def post(url, cookie, data, referer)
|
|
28
|
+
uri = URI.parse(url)
|
|
29
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
30
|
+
http.use_ssl = true
|
|
31
|
+
#http.set_debug_output STDERR
|
|
32
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
|
33
|
+
req["Content-Type"] = "application/x-www-form-urlencoded"
|
|
34
|
+
req["User-Agente"] = USER_AGENTE
|
|
35
|
+
req["Cookie"] = cookie
|
|
36
|
+
if referer != nil then
|
|
37
|
+
req["Referer"] = referer
|
|
38
|
+
end
|
|
39
|
+
req.body = data
|
|
40
|
+
res = http.request(req)
|
|
41
|
+
case res
|
|
42
|
+
when Net::HTTPSuccess then res
|
|
43
|
+
when Net::HTTPRedirection then res
|
|
44
|
+
else
|
|
45
|
+
res.error!
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def find_cookie(cookies, key)
|
|
50
|
+
fuelrid = ""
|
|
51
|
+
cookies.each do |cookie|
|
|
52
|
+
if(cookie.start_with?(key)) then
|
|
53
|
+
fuelrid = cookie.gsub(key, "")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
fuelrid
|
|
57
|
+
end
|
data/lib/weget/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: weget
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- shouaya
|
|
@@ -45,13 +45,21 @@ executables: []
|
|
|
45
45
|
extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
|
+
- ".DS_Store"
|
|
48
49
|
- ".gitignore"
|
|
49
50
|
- Gemfile
|
|
50
51
|
- README.md
|
|
51
52
|
- Rakefile
|
|
52
53
|
- bin/console
|
|
53
54
|
- bin/setup
|
|
55
|
+
- lib/.DS_Store
|
|
54
56
|
- lib/weget.rb
|
|
57
|
+
- lib/weget/.DS_Store
|
|
58
|
+
- lib/weget/analysis.rb
|
|
59
|
+
- lib/weget/cert.pem
|
|
60
|
+
- lib/weget/config.rb
|
|
61
|
+
- lib/weget/crawler.rb
|
|
62
|
+
- lib/weget/lib.rb
|
|
55
63
|
- lib/weget/version.rb
|
|
56
64
|
- weget.gemspec
|
|
57
65
|
homepage: https://shouaya.github.io
|