def self.fetch(doc_url, *args)
if args.size > 0
mechanize_doc = args[0][:mechanize_doc]
resolve = args[0][:resolve]
basic_auth = args[0][:basic_auth]
parse_and_set_basic_auth(basic_auth) if basic_auth
else
mechanize_doc = nil
resolve = :full
end
@@current_doc_url = doc_url
@@current_doc_protocol = determine_protocol
if mechanize_doc.nil?
handle_relative_path(doc_url) unless @@current_doc_protocol == 'xpath'
handle_relative_url(doc_url, resolve)
Scrubyt.log :ACTION, "fetching document: #{@@current_doc_url}"
case @@current_doc_protocol
when 'file': @@agent.goto("file://"+ @@current_doc_url)
else @@agent.goto(@@current_doc_url)
end
@@mechanize_doc = "<html>#{@@agent.html}</html>"
else
@@mechanize_doc = mechanize_doc
end
@@hpricot_doc = Hpricot(PreFilterDocument.br_to_newline(@@mechanize_doc))
store_host_name(@@agent.url)
end