Few hours ago, I just wondered if there is a Python library which I can use jQuerys selectors to do some tasks on HTML files. PyQuery came up in search results.

A quick example explains all:

from pyquery import PyQuery as pq

d = pq(url='http://makeyjl.blogspot.com')
for ele_post in d('div.post'):
  post = pq(ele_post)
  print post('h3.post-title a').text()
  print post('div.post-body').text()
  print

It prints out all post titles and contents in this blogs first page. Its quick and simple.