As a part of my Ruby learning process, i decided to write something to retrieve the full list of brands that Coca Cola currently owns from their website. The list is split across multiple pages, but with some Ruby magic and a nice library called Hpricot to traverse the HTML it was 5 minutes of [...]
Just a couple of pictures this time. The first one is about something i noticed i was doing, while searching for a code fragment. One could call it ironic, trying to find “find” The other is proof of my amazement by the fact that there was one person who visited my blog using an iPad [...]
As everyone already knows, Google Chrome now supports websockets. In essence, this allows you to keep a connection open with a webserver indefinitely (analogous to typical sockets) and send data bi-directionally. Unfortunately Chrome is the only browser currently supporting this, but I’m pretty sure this will change. So I decided to give this a try [...]
So, yeah, I resumed playing around with android, this time version 2.0. I’m really tempted to buy the new Motorola Milestone that should come out in Europe sometime between… now… and early next year, so I wanna be ready to create all the crazy stuff I have in mind for it One of the things [...]
At least a couple of options, the first using BeautifulSoup: import urllib import BeautifulSoup soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(“https://www.google.com”)) print soup.title.string And the second one using lxml: import lxml.html t = lxml.html.parse(url) print t.find(“.//title”).text
I recently ran into the following problem: I needed to be able to display a list of users in a table that had a maximum of X columns. Since I could not find the solution on the Internet I decided to give it a try and here is my resulting template filter to do it: [...]
Here’s how to, from a view, redirect to another URL passing parameters to it. For instance, to redirect the user to a certain page after login: return HttpResponseRedirect(reverse(‘dz_details’, kwargs={‘dz_id’:dz.id})) This will lookup the ‘dz_details’ name in your urls.py file, which could be defined like so: url(r’^details/(\d+)/$’, views.dz_details, name=’dz_details’), There is a simpler way to do [...]
Here’s how to redirect to the login page in django, making it go to a certain view (by name) after a successful login: login_url = ‘%s?next=%s’ % (reverse(‘acct_login’), reverse(‘jumplog_index’)) return HttpResponseRedirect(login_url) Notes: acct_login is django’s view name for the login page (double check this, as it might change in future django versions); jumplog_index is the [...]