开发者

Cross-domain proxy in Rails

I'm looking for a solution/gem/plugin to proxy load the HTML of any site with JS. I'm making something like Facebook's status update (add link) 开发者_高级运维form which crawls the link for images which will be displayed as a thumbnail.


If you want to fetch pages you have a lot of choices, everything from Net::HTTP which is part of Rails core, to the curb gem which employs the curl library.

If you want to parse the pages you get to extract the images you can use the nokogiri gem which will allow you to parse the HTML using CSS selectors.

If you're doing a lot of these requests and don't want the full overhead of Rails for what should be a simple proxy, you could always implement this using the sinatra gem, which is a much more light-weight model. Sinatra can be built into a full Rails app using the Rack infrastructure system so it fits in seamlessly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜