Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 576327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:02:08+00:00 2026-05-13T14:02:08+00:00

I thought that mechanize follows redirection by default … by my script ends at

  • 0

I thought that mechanize follows redirection by default … by my script ends at the redirection page. How can I handle this?

require 'rubygems'
require 'mechanize'

agent = WWW::Mechanize.new 

page = agent.get("http://www.vbulletin.org/forum/index.php")

login_form = page.form_with(:action => 'login.php?do=login')

login_form['vb_login_username'] = 'user name'
login_form['vb_login_password'] = ''
login_form['vb_login_md5password_utf'] = 'md5 hash from the password'
login_form['vb_login_md5password'] = 'md5 hash from the password'

page = agent.submit login_form

#Display welcome message if logged in
puts page.parser.xpath("/html/body/div/table/tr/td[2]/div/div").xpath('text()').to_s.strip

output = File.open("login.html", "w") {|f| f.write(page.parser.to_html) }

redirection page html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head>
<body>
<noscript>

    <meta http-equiv="Refresh" content="2; URL=http://www.vbulletin.org/forum/index.php">
</noscript>



    <script type="text/javascript">

    <!--

    function exec_refresh()

    {

        window.status = "Redirecting..." + myvar;

        myvar = myvar + " .";

        var timerID = setTimeout("exec_refresh();", 100);

        if (timeout > 0)

        {

            timeout -= 1;

        }

        else

        {

            clearTimeout(timerID);

            window.status = "";

            window.location = "http://www.vbulletin.org/forum/index.php";

        }

    }



    var myvar = "";

    var timeout = 20;

    exec_refresh();

    //-->

    </script><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="generator" content="vBulletin 3.6.12">
<meta name="keywords" content="vbulletin,forum,bbs,discussion,jelsoft,bulletin board,hacks,modifications,addons,articles,programming,site review">
<meta name="description" content="This is a discussion forum powered by vBulletin. To find out about vBulletin, go to http://www.vbulletin.com/ .">
<!-- CSS Stylesheet --><link rel="stylesheet" type="text/css" href="clientscript/vbulletin_css/style-befeb917-00023.css" id="vbulletin_css">
<link rel="stylesheet" type="text/css" href="clientscript/blue.css" id="blue">
<!-- / CSS Stylesheet --><script type="text/javascript">

<!--

var SESSIONURL = "";

var SECURITYTOKEN = "c1e3de2fd54e2938c4ab1e80ae448aa6bbea25b2";

var IMGDIR_MISC = "images/misc";

var vb_disable_ajax = parseInt("0", 10);

// -->

</script><script type="text/javascript" src="clientscript/vbulletin_global.js?v=3612"></script><link rel="alternate" type="application/rss+xml" title="vBulletin.org Forum RSS Feed" href="external.php?type=RSS2">
<!-- VB.ORG --><!-- The line above sets the script var and must be left in --><script type="text/javascript"> 

<!--

script = "login";

userid = "0";  

forumid = ""; 

threadid = ""; 

authorid = ""; 

// -->

</script><script type="text/javascript" src="clientscript/vborg_miscactions.js?v=3612"></script><!-- /VB.ORG --><title>vBulletin.org Forum</title>
<div id="container" style="border-width:0;width:950px">

<br><br><br><br><form action="http://www.vbulletin.org/forum/index.php" method="post" name="postvarform">

<table class="tborder" cellpadding="4" cellspacing="1" border="0" align="center">
<tr>
<td class="tcat">Redirecting...</td>

</tr>
<tr>
<td class="panelsurround" align="center">

    <div class="panel">



        <blockquote>

            <p> </p>

            <p><strong>Thank you for logging in, my username.</strong></p>          



                <p class="smallfont"><a href="http://www.vbulletin.org/forum/index.php">Click here if your browser does not automatically redirect you.</a></p>

                <div> </div>



        </blockquote>



    </div>

    </td>

</tr>
</table>
</form>





<br><br><br><br>
</div>



</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:02:08+00:00Added an answer on May 13, 2026 at 2:02 pm

    Are you sure it’s HTTP 30x Redirect response? Not normal “200 OK” response with page containing <meta http-equiv="refresh" content="100;url=...">. Mechanize follows first type of redirection, second is just normal response with link, which you should follow.

    I can’t check, because you didn’t posted username/password in code.

    Edit:
    After your update, this should be enough to follow redirection after login:

    page.link_with(:text => "Click here if your browser does not automatically redirect you.").click
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 386k
  • Answers 386k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My understanding is that a data access layer does not… May 14, 2026 at 11:44 pm
  • Editorial Team
    Editorial Team added an answer You can actually select the result which only has 3… May 14, 2026 at 11:44 pm
  • Editorial Team
    Editorial Team added an answer It is writing to the registry okay, just to the… May 14, 2026 at 11:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.