- #1
dacruick
- 1,042
- 1
Hi,
I am trying to access some data online, but I am having trouble getting past the actual authentication process.
The HTML code which corresponds to the Username, Password, and login button are respectively as follows.
After I try to access the sought after link, it redirects me back to the authentication page. So two possible things are happening. The first one is, I am not entering anything into the username and password fields. The second possibility is that I am not "clicking" the log in button, but instead am trying to open a page that I am not authenticated to open.
I am trying to access some data online, but I am having trouble getting past the actual authentication process.
Code:
import cookielib
import urllib, urllib2
if __name__ == '__main__':
urlLogin = '[PLAIN]https://www.hobolink.com'[/PLAIN]
uid = 'userid'
password = 'xxxxxxx'
fieldId = 'username'
fieldPass = 'password'
ButtonId = 'submit'
Button = 'Log in'
cj = cookielib.CookieJar()
data = urllib.urlencode({fieldId:uid, fieldPass:password, ButtonId:Button})
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
usock = opener.open(urlLogin)
usock = opener.open(urlLogin, data)
#pageSource = usock.read()
usock.close()
usock = opener.open('FinalWebpage')
pageSource = usock.read()
usock.close()
print(pageSource)
The HTML code which corresponds to the Username, Password, and login button are respectively as follows.
Code:
<input id="username" name="username" type="text">
Code:
<input id="password" name="password" type="password">
Code:
<li id="submit"><input class="button" name="commit" onclick="alertForExplorerBrowserVersion(7, 3);" type="submit" value="Log in"></li>
After I try to access the sought after link, it redirects me back to the authentication page. So two possible things are happening. The first one is, I am not entering anything into the username and password fields. The second possibility is that I am not "clicking" the log in button, but instead am trying to open a page that I am not authenticated to open.
Last edited by a moderator: