Take a look at this documentation of the urlib2
package. Below is the code you would use, but the documentation explains (very well) what is happening.
Excerpt:
import urllib
import urllib2
url = 'http://www.someserver.com/cgi-bin/register.cgi'
values = {'name' : 'Michael Foord',
'location' : 'Northampton',
'language' : 'Python' }
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
You would need to use an HTML parser like BeautifulSoup to obtain the parameter name and value that is being posted when you click the button.
Edit:
Yes, you could use mechanize for this as well. You would do something like this (untested):
from mechanize import Browser
br = Browser()
br.open("http://www.example.com/") # this would be your website
br.select_form(name="order") # change this to the name of your form
response = br.submit() # submits the form, just like if you clicked the submit button
print response.geturl() # prints the URL you are looking for
You'll need to make this specific to your website/form, but something along these lines should do the trick.
Check out the examples/documentation for the ClientForm
object if you find you need more control.