yanchenko
yanchenko

Reputation: 57176

Programmatically submitting a form in Python?

Just started playing with Google App Engine & Python (as an excuse ;)). How do I correctly submit a form like this

<form action="https://www.moneybookers.com/app/payment.pl" method="post" target="_blank">
<input type="hidden" name="pay_to_email" value="[email protected]">
<input type="hidden" name="status_url"
<!-- etc. -->
<input type="submit" value="Pay!">
</form>

w/o exposing the data to user?

Upvotes: 3

Views: 5593

Answers (2)

Jason Baker
Jason Baker

Reputation: 198577

It sounds like you're looking for urllib.

Here's an example of POSTing from the library's docs:

>>> import urllib
>>> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
>>> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
>>> print f.read()

Upvotes: 6

AKX
AKX

Reputation: 168967

By hiding the sensitive bits of the form and submitting it via JavaScript.

Make sure you have a good way of referring to the form element...

<form ... id="moneybookersForm">...</form>

... and on page load, execute something like

document.getElementById("moneybookersForm").submit();

At least I don't know of other ways. For JavaScript-disabled people, the Pay! button should be kept visible.

Upvotes: 0

Related Questions