# Post to a remote page

**URL:** <https://www.ruby-forum.com/t/post-to-a-remote-page/59165>\
**Category:** Rails\
**Created:** [April 29, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/post-to-a-remote-page/59165 "2006-04-29T15:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [April 29, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/post-to-a-remote-page/59165/1 "2006-04-29T15:57:59Z")

</div>

Hi all,

I am sorry if this question has already been replied here, but I did not  
manage to find an answer.

I am looking for a way to post data to a remote web page. I don’t want  
to use hidden fields and a submit button, I would just like some ruby  
code that would post parametres to a web page and store the web page  
that the remote server sends back.

I am not sure that I have been clear, so, here is an example.

I have a simple page on a php server B that contains the code

print ($\_POST[‘var1’]+$\_POST[‘var1’]);

And I have my ruby server A, and what I would like to do is post var1  
and var2 to server B and store the answer (A+B) that server B gives me  
back.

Is it possible to do such a thing?

I hope that someone will be able to help me!

Thank you very much!

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [April 30, 2006, 11:36pm UTC](https://www.ruby-forum.com/t/post-to-a-remote-page/59165/2 "2006-04-30T23:36:18Z")

</div>

You can use Net::HTTP to do an HTTP transfer inside of one of your  
scripts, and then save the result. I’ve never done it, but honestly, it  
shouldn’t be hard. Check  
[http://www.rubycentral.com/book/lib\_network.html](http://www.rubycentral.com/book/lib_network.html) for the API.

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [April 30, 2006, 11:56pm UTC](https://www.ruby-forum.com/t/post-to-a-remote-page/59165/3 "2006-04-30T23:56:52Z")

</div>

Great!

Thanks a lot!

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [May 3, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/post-to-a-remote-page/59165/4 "2006-05-03T19:08:31Z")

</div>

Are you bound to POST? You could use a REST-like approach and hit the  
remote page with GET requests via net/http and parse the response.
