How to connect to a website?

webmaster at terradon.nl webmaster at terradon.nl
Mon Apr 22 15:56:24 EDT 2013


thanks!
solved with:

import urllib.request
import urllib.parse

user = 'user'
pw = 'password'

login_url = 'http://www.riskopoly.nl/test/index.php'

data = urllib.parse.urlencode({'user': user, 'pw': pw})
data = data.encode('utf-8')
# adding charset parameter to the Content-Type header.
request = urllib.request.Request(login_url)
request.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")

f = urllib.request.urlopen(request, data)
print(f.read().decode('utf-8'))

And then i get next answer:
<pre>Array
(
    [pw] => password
    [user] => user
)
</pre>

Solved and thanks again:)



More information about the Python-list mailing list