
My usage of BeautifulSoup was very basic, all I needed to do was navigate to the desired element and then extract the uptime string:įor elem in soup('td', text="Connected time so far"): Opener.open(topLevelUrl + "/logout.html") # logout or nobody else can login Page = opener.open(topLevelUrl + "/welcome.html") # page with uptime info Handler = urllib2.HTTPBasicAuthHandler(passwordManager) PasswordManager.add_password(None, topLevelUrl, "username", "password")

PasswordManager = urllib2.HTTPPasswordMgrWithDefaultRealm() See below for how to open a page that requires authentication: This complicates things slightly, but not a great deal. The usage of urllib2 was almost the simplest use case except that my router requires a username/password combination to log in. I used this to parse the page with the uptime information and extract the uptime string. The boisterously named BeautifulSoup is a html parser that allows direct navigation of the underlying html. I used this to log in to my router and then read the contents of the page containing the uptime information.

Urllib2 allows you to retrieve files, pages etc from the web from within a python script. To make the script work there are two main python libraries that are necessary: urllib2 and BeautifulSoup. This approach is sound and is exactly the implementation I ended up with. My router has a web management interface that reports the current uptime of the connection to the internet so my thinking was to write a python script to log in to the router, extract the uptime data and from that detect when I had lost internet connection. The task to achieve this seemed immediately straightforward to me.

Anyway the Diablo experience enraged me enough that I decided to get some hard data about the stability of my internet connection. Was this an isolated incident or was my connection dropping consistently without my knowledge? I’ve had a few other drops in the past but not enough to really think there was a problem. But I was annoyed at my internet connection as well.

Blizzard take a bunch of the blame for making the game online only even for single player (seriously, what the hell?). Understandably I was a little irritated by this. So recently I was playing my hardcore character in Diablo 3 (hardcore means that death is permanent and irreversible) when my router lost internet connection and my character promptly died.
