Question

I was thinking about making an application that scrapes pages of my linksys router administration website. But since this is protected using a java login dialog I'm not able to get the webpage, look for elements (username, password) and then submit the data. Is there another way to do this?

Kind regards, Tobias

Was it helpful?

Solution

The following python code allowed me to extract the status page from my Linksys model WRT320N router:

import urllib2
from base64 import encodestring

LOGIN  = 'admin'
PASSWD = '<your router password>'
URL    = 'http://<router IP address>/Status_Router.asp'

url    = urllib2.Request(URL)
b64str = encodestring('%s:%s' % (LOGIN, PASSWD))[:-1]
url.add_header("Authorization", "Basic %s" % b64str)


f = urllib2.urlopen(url)
for line in f.readlines():
    print line,

f.close()

I was also able to do it with the "wget" utility using the user and password options.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top