# Visit a url programatically

**URL:** <https://www.ruby-forum.com/t/visit-a-url-programatically/188351>\
**Category:** Ruby\
**Created:** [May 10, 2010, 5:25pm UTC](https://www.ruby-forum.com/t/visit-a-url-programatically/188351 "2010-05-10T17:25:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kevid](https://www.ruby-forum.com/u/kevid)\
**Post date:** [May 10, 2010, 5:25pm UTC](https://www.ruby-forum.com/t/visit-a-url-programatically/188351/1 "2010-05-10T17:25:57Z")

</div>

hi all,

i have the code below;

require ‘rexml/document’  
require ‘open-uri’  
open(‘[http://api.evdb.com/rest/users/login?app\_key=ct2hJqTCg4XLCP5h](http://api.evdb.com/rest/users/login?app_key=ct2hJqTCg4XLCP5h)’)  
{ |f|  
$res = REXML::Document.new(f.read)  
}

the xml data that is read is;

\<?xml version="1.0" encoding="UTF-8"?\> 6984053721 Please supply a user authentication response using the nonce provided.

QUESTIONS

1. how do i get the value of nonce (i.e. 6984053721 )

2. is there another way of visiting the url “[http://api.evdb.com/rest/](http://api.evdb.com/rest/)  
users/login?app\_key=ct2hJqTCg4XLCP5h”  
without using open-uri as in above

thoughts??

---

<div class="post-metadata">

**Author:** ![kevid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kevid](https://www.ruby-forum.com/u/kevid)\
**Post date:** [May 10, 2010, 5:55pm UTC](https://www.ruby-forum.com/t/visit-a-url-programatically/188351/2 "2010-05-10T17:55:48Z")

</div>

On 2010-05-10 11:24:46 -0400, kevid said:

> thoughts??

I don’t mean to be rude, but you should read the corresponding API  
documentation.

[http://api.evdb.com/docs/auth](http://api.evdb.com/docs/auth)

The way you access a URL is good, the problem is about that specific  
one.  
The link I provide should direct you in the right direction.  
You also might want to check the mailing list, there is bound to be good  
info  
on whatever it is that you seek.

Have a good day!

---

<div class="post-metadata">

**Author:** ![kevid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kevid](https://www.ruby-forum.com/u/kevid)\
**Post date:** [May 19, 2010, 8:06pm UTC](https://www.ruby-forum.com/t/visit-a-url-programatically/188351/3 "2010-05-19T20:06:01Z")

</div>

I’m not sure specifically what you’re trying to do. If you’re trying to  
interact with a web sit, maybe Mechanize would be a better option of  
something to use?

[http://mechanize.rubyforge.org/mechanize/](http://mechanize.rubyforge.org/mechanize/)

-David

kevid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

---

<div class="post-metadata">

**Author:** ![kevid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kevid](https://www.ruby-forum.com/u/kevid)\
**Post date:** [May 20, 2010, 4:21pm UTC](https://www.ruby-forum.com/t/visit-a-url-programatically/188351/4 "2010-05-20T16:21:29Z")

</div>

To get the nonce node, just use an xpath:

require ‘rexml/document’  
require ‘open-uri’  
nonce = nil

open(‘[http://api.evdb.com/rest/users/login?app\_key=ct2hJqTCg4XLCP5h](http://api.evdb.com/rest/users/login?app_key=ct2hJqTCg4XLCP5h)’)  
{ |f|  
doc = REXML::Document.new(f.read)  
nonce = XPath.first(doc, “/error/nonce”)  
}
