M
Massi
Hi everyone, I'm trying to get data from an internet page which is
accessed from a login page. Looking at the html source code of the
login page I found that the name of the controls which handle username
and password are "login_un" and "login_pw". So I tried to write a
piece of code to access the data of the protected page:
import urllib2, urllib
opener = urllib2.build_opener()
login_data = urllib.urlencode({"login_un" : "my_un", "login_pw" :
"my_pw"})
opener.open('http://www.myprotectedsite.com/login_page', login_data)
resp = opener.open('http://www.myprotectedsite.com/hidden_page')
print resp.read()
But it doesn't work, since it prints the html code of the login page.
Can anyone point me out what I'm doing wrong?
Thanks in advance.
accessed from a login page. Looking at the html source code of the
login page I found that the name of the controls which handle username
and password are "login_un" and "login_pw". So I tried to write a
piece of code to access the data of the protected page:
import urllib2, urllib
opener = urllib2.build_opener()
login_data = urllib.urlencode({"login_un" : "my_un", "login_pw" :
"my_pw"})
opener.open('http://www.myprotectedsite.com/login_page', login_data)
resp = opener.open('http://www.myprotectedsite.com/hidden_page')
print resp.read()
But it doesn't work, since it prints the html code of the login page.
Can anyone point me out what I'm doing wrong?
Thanks in advance.