Simple blocks to use as a method to import a url in a rails app, like using content from another api
import HTML with Ruby (importHTML.rb) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| def importHTML
require 'open-uri'
@source = open("http://domain.com/some.html").read
end
# uses a reference parameter when getting remote XML
def importXML
require 'open-uri'
@aclass = AClass.find(params[:id]) # expecting a param named ref
@content = open("http://domain.com" + @aclass.ref + "&type=xml").read
respond_to do |format|
format.xml { render :xml => @content }
end
end
|