How do I access a web page from Sinatra?

淺唱寂寞╮ 提交于 2019-12-11 18:31:54

问题


I want to run this PHP script http://db2express/imacs/radek/3.1/rationalTest.php?mode=create from Sinatra. Sinatra runs on a different box.

Is there any Sinatra built-in way how to do that?

I know I can use mechanize, just wondering if there is something else to use?


回答1:


Open-URI will do a good job if all you need to do is retrieve the content of the URL or tickle some job at the other end of the URL.

If you need more control then Net::HTTP or Typhoeus are available.

Both Open-URI and Net::HTTP are part of Ruby's standard installation.

I just want to add further that "HTTParty" is a very good wrapper around "Net::HTTP" (see httparty.rubyforge.org)

Yes, I agree. It's nicely done. I reach for OpenURI first since it's built-in. HTTParty is lighter-weight than Typhoeus so it's nicely positioned between them.



来源:https://stackoverflow.com/questions/4094304/how-do-i-access-a-web-page-from-sinatra

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!