holden-hostelify 0.3.4 → 0.3.5
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.
- data/Manifest +16 -0
- data/Rakefile +1 -1
- data/hostelify.gemspec +2 -2
- data/lib/hostelify/hostelworld.rb +45 -10
- metadata +2 -2
data/Manifest
CHANGED
@@ -7,6 +7,22 @@ lib/hostelify/gomio.rb
|
|
7
7
|
lib/hostelify/hostelbookers.rb
|
8
8
|
lib/hostelify/hostelify.rb
|
9
9
|
lib/hostelify/hostelworld.rb
|
10
|
+
pkg/hostelify-0.3.5.gem
|
11
|
+
pkg/hostelify-0.3.5.tar.gz
|
12
|
+
pkg/hostelify-0.3.5/Manifest
|
13
|
+
pkg/hostelify-0.3.5/README.rdoc
|
14
|
+
pkg/hostelify-0.3.5/Rakefile
|
15
|
+
pkg/hostelify-0.3.5/hostelify.gemspec
|
16
|
+
pkg/hostelify-0.3.5/lib/hostelify.rb
|
17
|
+
pkg/hostelify-0.3.5/lib/hostelify/gomio.rb
|
18
|
+
pkg/hostelify-0.3.5/lib/hostelify/hostelbookers.rb
|
19
|
+
pkg/hostelify-0.3.5/lib/hostelify/hostelify.rb
|
20
|
+
pkg/hostelify-0.3.5/lib/hostelify/hostelworld.rb
|
21
|
+
pkg/hostelify-0.3.5/spec/_helper.rb
|
22
|
+
pkg/hostelify-0.3.5/spec/hb_find_by_hostel.spec
|
23
|
+
pkg/hostelify-0.3.5/spec/hb_find_hostels.spec
|
24
|
+
pkg/hostelify-0.3.5/spec/hw_find_by_hostel.spec
|
25
|
+
pkg/hostelify-0.3.5/spec/hw_find_hostels.spec
|
10
26
|
spec/_helper.rb
|
11
27
|
spec/hb_find_by_hostel.spec
|
12
28
|
spec/hb_find_hostels.spec
|
data/Rakefile
CHANGED
data/hostelify.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{hostelify}
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Holden Thomas"]
|
9
|
-
s.date = %q{2009-09-
|
9
|
+
s.date = %q{2009-09-23}
|
10
10
|
s.description = %q{Simple Hostel Webscrapper.}
|
11
11
|
s.email = %q{holden.thomas@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/hostelify.rb", "lib/hostelify/gomio.rb", "lib/hostelify/hostelbookers.rb", "lib/hostelify/hostelify.rb", "lib/hostelify/hostelworld.rb"]
|
@@ -106,7 +106,7 @@ class Hostelworld
|
|
106
106
|
if options[:date]
|
107
107
|
options = @default_options.merge(options)
|
108
108
|
date = Date.strptime(options[:date])
|
109
|
-
data =
|
109
|
+
data = setSearch2(url, options[:date], options[:no_ppl], options[:no_days])
|
110
110
|
else
|
111
111
|
data = parse_html(url)
|
112
112
|
end
|
@@ -153,20 +153,24 @@ class Hostelworld
|
|
153
153
|
#form = page.forms.first # => WWW::Mechanize::Form
|
154
154
|
form = page.form_with(:name => 'theForm')
|
155
155
|
|
156
|
-
page = agent.submit(form)
|
156
|
+
#page = agent.submit(form)
|
157
157
|
|
158
158
|
#form must be submitted twice because the people writing hostelworld are retards
|
159
159
|
#form = page.forms.first # => WWW::Mechanize::Form
|
160
|
-
form = page.form_with(:name => 'theForm')
|
161
|
-
form.field_with(:name => '
|
162
|
-
form.field_with(:name => '
|
163
|
-
form.field_with(:name => '
|
164
|
-
form.field_with(:name => 'NumNights').options[no_days.to_i-1].select
|
165
|
-
form.
|
166
|
-
|
160
|
+
#form = page.form_with(:name => 'theForm')
|
161
|
+
form.field_with(:name => 'selMonth2').options[month-1].select
|
162
|
+
form.field_with(:name => 'selDay2').options[day-1].select
|
163
|
+
form.field_with(:name => 'selYear2').options[year].select
|
164
|
+
#form.field_with(:name => { 0 => 'NumNights' }).options[no_days.to_i-1].select
|
165
|
+
my_fields = form.fields.select {|f| f.name == "NumNights"}
|
166
|
+
my_fields[1].value = no_days.to_i
|
167
|
+
#form.my_fields[1].whatever = "value"
|
168
|
+
#form.field_with(:name => 'Persons').options[no_ppl.to_i-1].select
|
169
|
+
#form.field_with(:name => 'Currency').options[4].select #US Currency
|
170
|
+
|
167
171
|
|
168
172
|
Retryable.try 3 do
|
169
|
-
page = agent.submit(form)
|
173
|
+
page = agent.submit(form, form.button_with(:name => 'DateSelect'))
|
170
174
|
end
|
171
175
|
|
172
176
|
error = page.search("div.microBookingError2")
|
@@ -180,10 +184,41 @@ class Hostelworld
|
|
180
184
|
return data
|
181
185
|
end
|
182
186
|
|
187
|
+
def self.setSearch2(url,date,no_ppl,no_days)
|
188
|
+
|
189
|
+
date = Date.strptime(date)
|
190
|
+
month = date.strftime("%m").to_i
|
191
|
+
day = date.strftime("%d").to_i
|
192
|
+
if Time.now.strftime("%y") == date.strftime("%y") then year = 0 else year = 1 end
|
193
|
+
|
194
|
+
agent = WWW::Mechanize.new
|
195
|
+
page = agent.get(url)
|
196
|
+
|
197
|
+
#the form name
|
198
|
+
#form = page.forms.first # => WWW::Mechanize::Form
|
199
|
+
form = page.form_with(:name => 'theForm')
|
200
|
+
|
201
|
+
#page = agent.submit(form)
|
202
|
+
|
203
|
+
#form must be submitted twice because the people writing hostelworld are retards
|
204
|
+
|
205
|
+
form.field_with(:name => 'selMonth').options[month-1].select
|
206
|
+
form.field_with(:name => 'selDay').options[day-1].select
|
207
|
+
form.field_with(:name => 'selYear').options[year].select
|
208
|
+
form.field_with(:name => 'NumNights').options[no_days.to_i-1].select
|
209
|
+
|
210
|
+
Retryable.try 3 do
|
211
|
+
page = agent.submit(form)
|
212
|
+
end
|
213
|
+
data = page.search("//div[@id='content']")
|
214
|
+
return data
|
215
|
+
end
|
216
|
+
|
183
217
|
def self.parse_availables(info)
|
184
218
|
|
185
219
|
availability = info.at('table[@id="tableDatesSelected2"]')
|
186
220
|
availability.search("div").remove
|
221
|
+
availability.search("span.hwRoomTypeDesc").remove
|
187
222
|
|
188
223
|
availables = []
|
189
224
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holden-hostelify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Holden Thomas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|