import urllib.parse
import urllib.request
url = 'https://www.w3schools.com/action_page.php'
headers = {
"User-Agent" : "Mozilla/5.0 (X11; U; Linux i686; " + \
"en-US; rv:1.9.2.24) Gecko/20111107 " + \
"Linux Mint/9 (Isadora) Firefox/3.6.24",
}
data = {'firstname':'Mickey', 'lastname':'Mouse'}
data = urllib.parse.urlencode(data)
data = data.encode('ascii')
req = urllib.request.Request(url, data, headers)
response = urllib.request.urlopen(req)
html = response.read()
print(html)
import urllib.request
url = 'https://www.redfin.com/city/30818'
headers = {
"User-Agent" : "Mozilla/5.0 (X11; U; Linux i686; " + \
"en-US; rv:1.9.2.24) Gecko/20111107 " + \
"Linux Mint/9 (Isadora) Firefox/3.6.24",
}
data = {}
req = urllib.request.Request(url, data, headers)
response = urllib.request.urlopen(req)
html = response.read()
print(html)