Sunday, January 4, 2015

from pattern.web import Google;

By Vasudev Ram


$ pip install pattern
from pattern.web import Google, plaintext

google = Google(language='en') 
for result in'"python"', cached=False):
        print unicode(plaintext(result.text))
    except UnicodeEncodeError:
        print "UnicodeEncodeError, skipping this tweet"
    except Exception:
        print "Exceptions happen"
$ python >t
$ less t # more coffee
The official home of the Python Programming Language.
Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows ...
The original implementation of Python, written in C.
Learn to program in Python, a powerful language used by sites like YouTube and Dropbox.
Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented ...
Welcome to the 3rd Edition of Learn Python the Hard Way. You can visit the companion site to the book at where you can ...
Python 3.4.2 documentation. Welcome! This is the documentation for Python 3.4.2, last updated Jan 01, 2015. Parts of the documentation: ...
Try Python in your browser ... Best way to learn Python for Raspberry Pi? ... Are there any python package that can intelligently parse strings containing numbers
Python 2.7.9 documentation. Welcome! This is the documentation for Python 2.7.9, last updated Dec 28, 2014. Parts of the documentation: ...
You can get xkcd shirts, prints, and posters in the store! Python ... Image URL (for

- Vasudev Ram - Dancing Bison Enterprises

Signup to hear about new products from me.

Contact Page


Anonymous said...

Why does a UnicodeDecodeError mean the result is a tweet?!

Vasudev Ram said...

It does not mean it is a tweet. It was an error while modifying code from the earlier post which was for Twitter search, while this post is for Google search (both using pattern.web). See the link in the "pip install pattern" line, for the earlier post. I usually proof-read the code, text and links in the post before hitting publish, but missed this one ...

Vasudev Ram said...

So it should really read "skipping this result". But I'm not going to make the change in the post itself, since that will mean readers via feed readers or aggregators will get the post twice.