PyQuery – Bringing jQuery Syntax to Python

If BeautifulSoup has ever felt unwieldily or you’ve looked upon Ruby’s NokoGiri with envy then you may find this funky Python library interesting.

PyQuery brings jQuery selector syntax to Python. If you’re already familiar with jQuery selectors you’ll be right at home. Even if you don’t its easy enough to pick up.

Here’s a quick example:

from pyquery import PyQuery as pq

d = pq(url="http://www.straw-dogs.co.uk")
# d is now like the jQuery $

for post in d('div.post'):
	p = pq(post)
	print p('h2').text()

Get it here.

PyQuery is also available to install via “pip”.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • BlinkList
  • DZone
  • Live
  • Ma.gnolia
  • Reddit
  • Slashdot
  • SphereIt
  • StumbleUpon

Related posts:

  1. Python 3.0 Breaks Backwards Compat
  2. Python Virtual Host Creator
  3. Finally – A Python HTTP Lib that’s as nice as…
  4. Python: Beginner to Expert
  5. Ruby and Python Compared

Comments are closed.