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 6202763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:47:44+00:00 2026-05-24T04:47:44+00:00

So, I started out with Mechanize, and apparently the first thing I try it

  • 0

So, I started out with Mechanize, and apparently the first thing I try it on is a monkey-rhino-level high JavaScript navigated site.

Now the thing I’m stuck on is submitting the form.

Normally I’d do a submit using the Mechanize built-in submit() function.

import mechanize

browser = mechanize.Browser()
browser.select_form(name = 'foo')
browser.form['bar'] = 'baz'
browser.submit()

This way it’d use the submit button that’s available in the HTML form.

However, the site I’m stuck on had to be one that doesn’t use HTML submit buttons… No, they’re trying to be JavaScript gurus, and do a submit via JavaScript.

The usual submit() doesn’t seem to work with this.

So… Is there a way to get around this?

Any help is appreciated. Many thanks!

–[Edit]–

The JavaScript function I’m stuck on:

function foo(bar, baz) {
    var qux = document.forms["qux"];

    qux.bar.value = bar.split("$").join(":");
qux.baz.value = baz;
qux.submit();
}

What I did in Python (and what doesn’t work):

def foo(browser, bar, baz):
    qux = browser.select_form("qux")

    browser.form[bar] = ":".join(bar.split("$"))
    browser.form[baz] = baz
    browser.submit()
  • 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-24T04:47:45+00:00Added an answer on May 24, 2026 at 4:47 am

    Three ways:

    The first method is preferable if the form is submitted using the POST/GET method, otherwise you’ll have to resort to second and third method.

    1. Submitting the form manually and check for POST/GET requests, their parameters and the post url required to submit the form. Popular tools for checking headers are the Live HTTP headers extension and Firebug extension for Firefox, and Developer Tools extension for Chrome. An example of using the POST/GET method:

      import mechanize
      import urllib
      
      browser = mechanize.Browser()
      #These are the parameters you've got from checking with the aforementioned tools
      parameters = {'parameter1' : 'your content',
                    'parameter2' : 'a constant value',
                    'parameter3' : 'unique characters you might need to extract from the page'
                   }
      #Encode the parameters
      data = urllib.urlencode(parameters)
      #Submit the form (POST request). You get the post_url and the request type(POST/GET) the same way with the parameters.
      browser.open(post_url,data)
      #Submit the form (GET request)
      browser.open(post_url + '%s' % data)
      
    2. Rewrite the javascript and execute it in Python. Check out spidermonkey.

    3. Emulate a full browser. Check out Selenium and Windmill.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Back in the 90s when I first started out with MFC I used to
I've just started building a prototype application in Django. I started out by working
I'm getting started on figuring out how to use RESTful design. I have this
I started an application in Google App Engine right when it came out, to
I've just started learning Lisp and I can't figure out how to compile and
I have just started learning Erlang and am trying out some Project Euler problems
I started programming C# applications when the 1.0 framework was first released. I worked
Just today I've started using Drupal for a site I'm designing/developing. For my own
I've just started out trying MVC 2 and Ajax, and I'm wondering if I'm
I've started out with the Silverlight 4 Navigation Application template (RIA Services enabled). (As

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.