473,411 Members | 1,991 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,411 software developers and data experts.

Automatic web form transactions

We've been using the excellent ClientForms module with
urllib2 to read forms, fill them in, and then submit
with 'response = urlopen(form.click())'. The process
usually works very well.

But some forms, which work straightforward in a
browser, don't work with form.click(). For instance,
in one simple form the response is:

"Sorry, this form cannot be posted to from external source."

I'm wondering if the reason it generates that response is
because it is looking for a standard browser. In that
case, I should be able to send some browser string that it likes.
I don't think I can use the webbrowser module because
while that lets you launch a browser, it doesn't have an
interface to fill in forms, click the submit button, and so on.

One obvious long term solution is for me to learn much
more about the details of html form processing, especially
low level details in the htmllib and ClientForm modules.
But a nice quick solution would be helpful too.

If its any use, the offending form is:

<form method=post action=/additem.php name=TaskForm>
<table border=0 cellpadding=4 cellspace=4>
<tr>
<td bgcolor=000090 width=95 align=left>
<font face=arial size=2 color=ffffff>
New Loc
</font>
</td>
<td bgcolor=000090 align=left>
<font size=2 face=arial color=ffffff>
<input type=text name=newLoc value="http://" size=25 maxlength=255>
</td>
<td bgcolor=000090 align=center colspan=2>
<font size=1 face=arial>
<input type=submit value="Submit Form">
<input type=reset value="Clear Form">
</td>
</tr>
</table>
<form>

Thanks,

J
Jul 18 '05 #1
1 4271
DH
Jay Davis wrote:
We've been using the excellent ClientForms module with
urllib2 to read forms, fill them in, and then submit
with 'response = urlopen(form.click())'. The process
usually works very well.

But some forms, which work straightforward in a
browser, don't work with form.click(). For instance,
in one simple form the response is:

"Sorry, this form cannot be posted to from external source."


The web form script (additem.php) might be checking the referrer.
Set the http request referrer header to a URL the the URL of the webform.

See if something like this works:
request = form.click()
request.add_header("Referrer", "url of the form")
response = urlopen(request)

If that doesn't work, maybe it is checking a cookie or something.
You could replace urlopen with ClientCookie.urlopen maybe.
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Richard Maher | last post by:
Hi, I am seeking the help of volunteers to test some software that I've developed which facilitates distributed two-phase commit transactions, encompassing any resource manager (e.g. SQL/Server...
1
by: Me | last post by:
Hi, In my application, I have two records, customers and transactions.Each customer may have many transactions and so I have created a one to many relationship between them. I have a form...
1
by: Ron | last post by:
I have a pre-printed form that I've basically duplicated in Access 2000 with the form wizards. It uses a main form for the basic info on a client, then a subform for the transaction lines. I've...
1
by: Nico | last post by:
Hi! I use Windows XP and Access 2002 (XP) SP2 (not SP3) My company has not upgraded to SP3. My problem: -I have a form "F_BOMs" -in this form, i have a sub form called "SF_BOMs" -the sub-form...
1
by: SorboPos | last post by:
Hi. I have a form with continuous forms and a data entry section in the header of the form. (I.e. all transactions show in the main form area like a data sheet and the data for the highlighed...
11
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few...
3
by: john | last post by:
I have a form with Members and in that form a subform with Transactions. Those are linked (on banknr) 1xM which I've set in the database relations. Now I would like to copy the form and modify it....
14
by: Anja | last post by:
Hi everyone, I have a sub form that references a query to get the results. However, what I want to do is filter the results further based on a certain criteria. How can I tell the sub form to...
15
by: Kevin Davis | last post by:
Hello, I'm a new person when it comes to PHP and I have a quick question. I would like to create a form that will allow the user to add more information using the same form in case they have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.