mechanize login form

Discussion in 'Ruby' started by Pen Ttt, Jun 16, 2010.

  1. Pen Ttt

    Pen Ttt Guest

    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=d6179312144b3f8cf843d61b0ba409ca')
    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/.
     
    Pen Ttt, Jun 16, 2010
    #1
    1. Advertising

  2. Pen Ttt

    Josh Cheek Guest

    Re: mechanize login form

    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?mode=3Dlogin&sid=3Dd6179312144b3f8cf84=

    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/22/new-stuff-in-ruby-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.
     
    Josh Cheek, Jun 16, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. elca
    Replies:
    0
    Views:
    537
  2. elca
    Replies:
    0
    Views:
    739
  3. Md.elme focruzzaman Shuvo

    Need Help in Aol Login with mechanize

    Md.elme focruzzaman Shuvo, Jun 17, 2007, in forum: Ruby
    Replies:
    0
    Views:
    139
    Md.elme focruzzaman Shuvo
    Jun 17, 2007
  4. Frioffol Friofool
    Replies:
    0
    Views:
    259
    Frioffol Friofool
    Oct 4, 2007
  5. Rita Amritkar
    Replies:
    0
    Views:
    106
    Rita Amritkar
    Dec 28, 2007
Loading...

Share This Page