Class: Oddb2xml::SwissmedicInfoDownloader
Instance Attribute Summary
Attributes inherited from Downloader
#agent, #type
Instance Method Summary
collapse
Methods inherited from Downloader
#initialize
Instance Method Details
#download ⇒ Object
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
# File 'lib/oddb2xml/downloader.rb', line 303
def download
file = File.join(Downloads, "swissmedic_info.zip")
FileUtils.rm_f(file, :verbose => false) unless Oddb2xml.skip_download?
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
rescue Timeout::Error, Errno::ETIMEDOUT
retrievable? ? retry : raise
rescue NoMethodError
ensure
Oddb2xml.download_finished(file)
end unless File.exists?(file)
read_xml_from_zip(/^AipsDownload_/iu, file)
end
|
#init ⇒ Object
298
299
300
301
302
|
# File 'lib/oddb2xml/downloader.rb', line 298
def init
super
@agent.ignore_bad_chunking = true
@url ||= "http://download.swissmedicinfo.ch/Accept.aspx?ReturnUrl=%2f"
end
|