473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Selecting a single form amongst many with mechanize

I've been trying to select the 2nd form out of 20+ forms in a page. And it happens to be the only form in the page with a name 'send_form'.

I've tried
Expand|Select|Wrap|Line Numbers
  1. br.select_form(nr=1)
and
Expand|Select|Wrap|Line Numbers
  1. br.select_form(name='send_form')
and
Expand|Select|Wrap|Line Numbers
  1. for f in br.forms():
  2.     if f.name != None:
  3.         br.select_form(name=f.name)
The first results in every single form object from the page. The second returns a no form by that name error. And the third also returns every single form object on the page.

Now there are three fields I'm trying to access name=prospect_email[], name=prospect_name[], name=prospect_telephone[]. Now these input fields also have id's with the same name lacking the []. Now I've successfully input data into fields on other forms so I know how to do it. But when I try to access these I get an error saying the name of ... does not exist. I was figuring it's probably because I don't have the right form selected. I've spent hours on this and I'm racking my brain trying to figure it out. Help will be appreciated.
Jun 30 '10 #1
2 3377
@burntbit
I apologize. I tried to replicate it and I couldn't. And I tried the code again and it worked. So I'm a bit surprised. Here's the code that worked.

Expand|Select|Wrap|Line Numbers
  1. br.select_form(nr=1)
  2.  
  3.  
  4. br.form['prospect_email[]'] = 'example@google.com'
  5. br.form['prospect_name[]'] = 'Example Name'
  6. br.form['prospect_telephone[]'] = '1234567890'
  7.  
  8. br.submit()
It was my mistake. The script actually loads through 3 other page forms before it gets to this point. There's a login, and then two redirect pages with hidden forms. I go through those quite easily. And then it's as I described. I spent most of a night trying code and ran into problems... but I try the same code today and it works.
Jul 1 '10 #2
bvdet
2,851 Expert Mod 2GB
@burntbit
Thanks for the update burntbit.
Jul 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt C. | last post by:
I've got an application that has several distinct functions. I'd like to make these available as different screens that the user can switch between within a single form, using commands from the...
1
by: RLN | last post by:
Re: Access 2000 I have a form (Form1) where the default view in the properties is set to "Datasheet". When I click on the Form1 object from the container to display it, it displays fine in...
0
by: misscrf | last post by:
I am currently working on a database, in 3rd normal form, which is for candidates who apply for a job with the law firm that I workd for. My issue is with good form design. I have a main...
1
by: iMedia User | last post by:
I have a site where I want to use the Web form validators in two separate forms on a single page. One form allows existing users to log in while the second one allows new users to register. The...
1
by: Maileen | last post by:
Hi, How can i do (and test) a single instance of my form ? thanks, Maileen
2
by: Gary Shell | last post by:
Sorry for the crosspost, I initially posted this to the microsoft.public.dotnet.languages.vb.data group, but it never showed up there. (Is that newsgroup still active???) I have two datasets...
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
5
by: neehakale | last post by:
Im new to C# and im doing a project that requires to integrate many forms in a single form. for eg, Form1 is my main form. when i clicked on a button or links in the main form the new form should...
2
by: nduerr | last post by:
I am looking for the VB code to switch the way a form opens on click event. Specifically I have a form created with a default split view setting. I would like to open this form in single form...
1
by: gershwyn | last post by:
Hey all, another question about split forms in Access 2007. Hopefully this one is a quick one. I have a bound spit form for data entry. The split form portion does not allow edits. I want it to be...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.