Updated 2007-06-25 20:42:24 by EMJ

SS 24Aug2004: xadsen is a monitor for "GOOGLE ADSENSE"(*) that runs as a little window in your desktop (like xmem, xbiff, and so on). xadsen will show the earning for today and yesterday, together with the percentage and number of clicks for the two days, this will allow you to stay informed about your earning without to have to log multiple times in your "ADSENSE"(*) account, but just looking at the xadsen window in your desktop. xadsen is Free Software, under the terms of the GPL license.

The program can be downloaded from http://www.hping.org/xadsen

Implementation notes:

xadsen is an example of the Tcl/Tk ability to let the programmer to create a useful application in five minutes. The problem was to create an HTTPS request in order to Login into Google, get the cookie information, and send another HTTPS request with the authentication coockie set in order to get the CSV file with the earning data. Once we have the CSV file, there is just a little parsing to do, and some basic Tk in order to display the information on a little window.

The first problem was about the HTTPS request. Because xadsen was a very specialized application, it wasn't too important to have the ability to have a general HTTPS engine, so I just captured the headers my real browser (Mozilla) send to Google when I perform the login, and the header of the CSV request. I used "Live HTTP headers" plugin of mozilla in order to capture the headers. The Tcl application started with two hard-coded strings containing the HTTP headers: the program will use this headers as a template (substituting the non constant part via [string map]).

The second problem was that HTTPS runs over SSL. With Tcl this was trivial, I just used the TLS extension, that's really great. Just replace the socket command with tls::socket and you are done! Very great. At this point all was trivial, I send the first request using TLS, and the HTTP request template, than parse the response to get the Cookies, and resend another request (that's again a template where the programm will substitute the cookies with the right value). The output of the second request is the CSV file.

The Tk part is too trivial to be explained. I think this little utility shows again how the Tcl programming language is able to solve real-world problems with minimal efforts because of its flexibility and powerful handling of strings.
 (*) GOOGLE and ADSENSE are trademarks of Google Inc.

Category Internet