问题
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