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

Automated form submission

Thekid
145 100+
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="submitform" action="/website.here" method="post"><br />
Answer:
<input size="50" name="solution"><br /><br />
<div style="text-align:center">
<input name ="submitbutton" type="submit" value="submit (remaining time: 3 seconds)">
</div>
</form>
************************************************** *******************************************
<form name="submitform" action="/website.here" method="POST"><br />
Answer: <br />
<input size="75" name="solution"><br /><br />
<div style="text-align:center">
<input name ="submitbutton" 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 1812

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

Similar topics

9
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) ...
2
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...
6
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...
8
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
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...
9
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...
1
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...
1
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
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.