Automatic web form transactions
DH
no at sp.am
Wed Mar 3 16:37:55 EST 2004
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.
More information about the Python-list
mailing list