Python script autofill html form

429 Views Asked by At

The following script puts the required values into the single form on the webpage, but how do I make it 'submit' the values, proceed to the next page and show the page filled in as if i'd proceeded manually, please?

I've looked through the other related posts, but they don't do what I'd like. Here is the script:

import urllib
import urllib2
import requests
import webbrowser
url = 'https://www.example.com'
payload = {'number': '1237777', 'surname': 'xxxxxxx'}
data = urllib.urlencode(payload)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page   # checked form contents here

The html code shows the values inserted.

0

There are 0 best solutions below