Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > mechanize login form

Reply
Thread Tools

mechanize login form

 
 
Pen Ttt
Guest
Posts: n/a
 
      06-16-2010
i'm gona to simulate login my ubuntu forum,here is my program

require 'rubygems'
require 'mechanize'
agent = Mechanize.new
page =
agent.get('http://forum.ubuntu.org.cn/ucp.php?mode=login&sid=d6179312144b3f8cf843d61b0ba 409ca')
uform = page.forms[1]
uform.username = '罗非鱼'
uform.password = '*****'
uform.action = 'http://forum.ubuntu.org.cn/ucp.php?mode=login'
page = agent.submit(uform)
page.save('/home/pt/ubuntu')

attention: keyword is absolutely right,here is ommitted.
i found that i haven't longin when i open the file /home/pt/ubuntu
with firefox.
would you mind to tell me what the matter is in my program?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Josh Cheek
Guest
Posts: n/a
 
      06-16-2010
On Wed, Jun 16, 2010 at 12:18 AM, Pen Ttt <> wrote:

> i'm gona to simulate login my ubuntu forum,here is my program
>
> require 'rubygems'
> require 'mechanize'
> agent =3D Mechanize.new
> page =3D
> agent.get('
> http://forum.ubuntu.org.cn/ucp.php?m...12144b3f8cf84=

3d61b0ba409ca
> ')
> uform =3D page.forms[1]
> uform.username =3D '=E7=BD=97=E9=9D=9E=E9=B1=BC'
> uform.password =3D '*****'
> uform.action =3D 'http://forum.ubuntu.org.cn/ucp.php?mode=3Dlogin'
> page =3D agent.submit(uform)
> page.save('/home/pt/ubuntu')
>
> attention: keyword is absolutely right,here is ommitted.
> i found that i haven't longin when i open the file /home/pt/ubuntu
> with firefox.
> would you mind to tell me what the matter is in my program?
> --
> Posted via http://www.ruby-forum.com/.
>
>

Mechanize has its own set of cookies. So you could be logged in with
Mechanize, and not logged in with Firefox. I found a blog where tenderlove
says you can serialize cookies (
http://tenderlovemaking.com/2006/06/...mechanize-050/), s=
o
there is probably a way to share them with Fx, but it might take some effor=
t
to find or write, I really don't know.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: mechanize login problem with website elca Python 0 11-19-2009 08:50 PM
mechanize login problem with website elca Python 0 11-19-2009 04:18 AM
login to lonked in is failing with Mechanize Rita Amritkar Ruby 0 12-28-2007 10:27 AM
newbie - mechanize multiple cookies problem with form login Frioffol Friofool Ruby 0 10-04-2007 01:01 PM
Need Help in Aol Login with mechanize Md.elme focruzzaman Shuvo Ruby 0 06-17-2007 01:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57