Class: Oddb2xml::SwissmedicInfoDownloader
Instance Method Summary
collapse
Methods inherited from Downloader
#initialize
Instance Method Details
#download ⇒ Object
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
# File 'lib/oddb2xml/downloader.rb', line 264
def download
file = "swissmedic_info.zip"
begin
response = nil
if home = @agent.get(@url)
form = home.form_with(:id => 'Form1')
bttn = form.button_with(:name => 'ctl00$MainContent$btnOK')
if page = form.submit(bttn)
form = page.form_with(:id => 'Form1')
bttn = form.button_with(:name => 'ctl00$MainContent$BtnYes')
response = form.submit(bttn)
end
end
if response
response.save_as(file)
response = nil
end
return read_xml_form_zip(/^AipsDownload_/iu, file)
rescue Timeout::Error, Errno::ETIMEDOUT
retrievable? ? retry : raise
rescue NoMethodError
ensure
deleted = false
if File.exists?(file)
until deleted
begin
File.unlink(file)
deleted = true
rescue Errno::EACCES
end
end
end
end
end
|
#init ⇒ Object
259
260
261
262
263
|
# File 'lib/oddb2xml/downloader.rb', line 259
def init
super
@agent.ignore_bad_chunking = true
@url ||= "http://download.swissmedicinfo.ch/Accept.aspx?ReturnUrl=%2f"
end
|