# Get file from web page that require user and pass

**URL:** <https://www.ruby-forum.com/t/get-file-from-web-page-that-require-user-and-pass/171251>\
**Category:** Ruby\
**Created:** [June 29, 2009, 4:16pm UTC](https://www.ruby-forum.com/t/get-file-from-web-page-that-require-user-and-pass/171251 "2009-06-29T16:16:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kga85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/90ced4/32.png) [@kga85](https://www.ruby-forum.com/u/kga85)\
**Post date:** [June 29, 2009, 4:16pm UTC](https://www.ruby-forum.com/t/get-file-from-web-page-that-require-user-and-pass/171251/1 "2009-06-29T16:16:34Z")

</div>

I want to connect to a web site that require user name and password.  
This adress holds a file, like a txt, image pdf and so on. I want to get  
this payload. (Only going to check if the file is is empty or not).

I Have tryed a billion different ways, but i cant get it to work. I get  
errors and stuff. The last error is like this.

/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError) from /usr/lib/ruby/1.8/net/http.rb:560:in `open’  
from /usr/lib/ruby/1.8/net/http.rb:560:in `connect' from /usr/lib/ruby/1.8/timeout.rb:53:in `timeout’  
from /usr/lib/ruby/1.8/timeout.rb:93:in `timeout' from /usr/lib/ruby/1.8/net/http.rb:560:in `connect’  
from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start' from /usr/lib/ruby/1.8/net/http.rb:542:in `start’  
from /usr/lib/ruby/1.8/net/http.rb:1035:in `request' from waste/waste.rb:20:in `get\_feed’

And here i even tryed a code som other guy made, it is on this site:

> **[Ruby HTTPS with HTTP Basic Auth](http://blog.patrick-morgan.net/2007/02/ruby-https-with-http-basic-auth.html)**
>
> Fetching HTTPS data with Ruby using HTTP Basic Authorization require 'net/http' require 'net/https' def get\_feed(server,path,username,passwo...

So how do i get the file that are stored on a web page that require  
username and password?

---

<div class="post-metadata">

**Author:** ![kga85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/90ced4/32.png) [@kga85](https://www.ruby-forum.com/u/kga85)\
**Post date:** [June 29, 2009, 4:28pm UTC](https://www.ruby-forum.com/t/get-file-from-web-page-that-require-user-and-pass/171251/2 "2009-06-29T16:28:29Z")

</div>

On Mon, Jun 29, 2009 at 10:16 AM, Kga A.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> from /usr/lib/ruby/1.8/net/http.rb:560:in `open’  
> [Pixels and Politics: Ruby HTTPS with HTTP Basic Auth](http://blog.patrick-morgan.net/2007/02/ruby-https-with-http-basic-auth.html)
> 
> ## So how do i get the file that are stored on a web page that require username and password?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

I address authentication in my Twitter articles. Here’s one that show  
you how to use basic\_auth.

> **[Store Website Visitor Information With Cookies](https://www.thoughtco.com/using-cookies-with-php-2693786)**
>
> Cookies store information about a visitor to a website on the visitor's computer. Set cookies using PHP to preserve visitor information.

Without seeing your code, it’s hard to say where exactly you went wrong.
