473,583 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automated form submission

Thekid
145 New Member
I'm trying to auto send a form submission to a website but it isn't working. I've done this before and it worked but for some reason, using the same basic code, it doesn't seem to submit it. I'm using urllib & urllib2 to open the page and re to parse the info. On the page is a text entry field and a 'submit' button. I've compared the source code of both pages and they appear the same as far as the submission goes. Anything else I can try? I don't want to bother with Beautiful Soup right now because I'm very close with what I have. On the page is:
Answer:
'submit button'

What I've used:
Expand|Select|Wrap|Line Numbers
  1. import urllib2
  2. import urllib
  3. import re
  4.  
  5. url='http://website.here'
  6. strSession='cookie.info.here'
  7. dicHeaders={'COOKIE':strSession}
  8. req=urllib2.Request(url, None, dicHeaders)
  9. f=urllib2.urlopen(req)
  10. strContext=f.read()
  11. out=open("data.txt","w")
  12. out.write(strContext)
  13. out.close()
  14. infile=open("data.txt","r")
  15.  
  16. *re code here*
  17.  
  18.         answer=10 # answer varies
  19.         print answer
  20.         password=urllib.urlencode({'solution':answer})
  21.         req2=urllib2.Request(url,password,dicHeaders)
  22.         f2=urllib2.urlopen(req2)
  23.         print f2.read()
  24.  
  25.  
If I test it like this on the previous page that it worked on, I get the response that says "Sorry, your answer is wrong" which is fine because I know it submitted the answer but on the current page (which is very similar) it doesn't seem to submit it.
Here are the form actions of both pages for comparison. The first is the one that previously worked, the 2nd the new one I'm trying.

*************** *************** *************** *************** *************** *************** **
<form name="submitfor m" action="/website.here" method="post">< br />
Answer:
<input size="50" name="solution" ><br /><br />
<div style="text-align:center">
<input name ="submitbutt on" type="submit" value="submit (remaining time: 3 seconds)">
</div>
</form>
*************** *************** *************** *************** *************** *************** ***
<form name="submitfor m" action="/website.here" method="POST">< br />
Answer: <br />
<input size="75" name="solution" ><br /><br />
<div style="text-align:center">
<input name ="submitbutt on" type="submit" value="Submit (remaining time: 5 seconds)">
</div>

</form>
*************** *************** *************** *************** *************** *************** ***

Is there another way for me to get this answer to send?
Feb 5 '09 #1
0 1824

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

Similar topics

9
2002
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) Eliminate the submit button and submit the form with onchange. 2) Open the action php page in a new window. I am using this code for different payment...
2
7035
by: Andy Goldstein | last post by:
I have a table where all the TRs have an onClick handler registered. One (and only one) of the rows has 2 text input boxes, where each textbox has an onChange handler registered. Both the onClick and onChange handlers do some minor manipulation of form data (although they work on different form elements). If the onChange event fires, I need...
6
3050
by: brettev | last post by:
World, I work at a university where the professors have a system to input grades for assignments and calculate final grades, which is output to an excel file. they are then required to get on a different system and click radio buttons in a form to input final grades. i would like to automate this by doing some sort of automated form...
8
4775
by: yawnmoth | last post by:
Say I have the following HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="">
6
11880
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks again, which created duplicate forcm submission and hence duplicate records. So I am trying to disable the button as soon as it is clicked,...
9
3882
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they...
1
2498
by: Homer | last post by:
Hi, I just got a requirement from my HR department to automate their form submission process and integrate it into the Intranet project that I had just completed Phase 1 of. Because of the short time frame that I've been given, a week to be exact, I do not have the luxury to explore it on my own so here are the requirements: 1. Automate...
1
2250
by: rn5arn5a | last post by:
Nowadays, most websites make use of CAPTCHA to prevent automated Form submission. Can someone please give me examples of how automated Form submission can be achieved? It's not that I intend to do some nefarious activities; rather I don't understand how can automated Form submission be done other than the website developer coding it (for...
8
4346
Megalog
by: Megalog | last post by:
Hey guys.. my turn to ask a question: I'm having a weird issue with a form I've reworked. This form has a combo box, which when used is changing the recordsource of a subform. This subform has no Master/Child relationship set to the main form. Specifically the problem seems to be that everytime the recordsource of the subform is changed, the...
0
7826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8327
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6579
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5374
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3818
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.