lost and found ( for me ? )

Python : use google search engine

Here is how to use google search engine with Python pygoogle.

Reference
https://code.google.com/p/pygoogle/

install pygoogle on Ubuntu 12.04.
# apt-get install subversion

# svn checkout http://pygoogle.googlecode.com/svn/trunk/ pygoogle-read-only
A    pygoogle-read-only/setup.py
A    pygoogle-read-only/pygoogle.py
Checked out revision 7.

# cd pygoogle-read-only/

# python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying pygoogle.py -> build/lib.linux-x86_64-2.7

# python setup.py install
running install
running build
running build_py
running install_lib
copying build/lib.linux-x86_64-2.7/pygoogle.py -> /usr/local/lib/python2.7/dist-packages
byte-compiling /usr/local/lib/python2.7/dist-packages/pygoogle.py to pygoogle.pyc
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/pygoogle-0.1.egg-info
#



# python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pygoogle import pygoogle
>>> g = pygoogle('ubuntu linux')
>>> g.pages = 3
>>> print g.get_result_count()
19900000
>>> print g.get_urls()
[u'http://www.ubuntu.com/', u'http://www.ubuntu.com/download', u'http://www.ubuntu.com/download/desktop', u'http://www.ubuntu.com/desktop', u'http://en.wikipedia.org/wiki/Ubuntu_(operating_system)', u'http://en.wikipedia.org/wiki/Ubuntu', u'http://distrowatch.com/ubuntu', u'http://www.pcworld.com/article/2013431/10-reasons-to-choose-ubuntu-12-10-over-windows-8.html', u'http://ubuntustudio.org/', u'http://ubuntuforums.org/', u'http://www.videolan.org/vlc/download-ubuntu.html', u'http://xubuntu.org/', u'http://www.zdnet.com/openstacks-top-operating-system-ubuntu-linux-7000027360/', u'http://www.edubuntu.org/', u'https://www.facebook.com/ubuntulinux', u'http://www.getdeb.net/', u'http://cran.r-project.org/bin/linux/ubuntu/', u'http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/', u'http://lifehacker.com/5993297/ubuntu-vs-mint-which-linux-distro-is-better-for-beginners', u'http://www.youtube.com/watch?v=vIIAfXuIy-g', u'http://www.dell.com/us/business/p/xps-13-linux/pd', u'http://www.amazon.com/Ubuntu-Linux-Toolbox-Commands-Debian/dp/1118183525', u'http://www.amazon.com/Practical-Guide-Ubuntu-Linux-Edition/dp/013254248X', u'http://www.kubuntu.org/']
>>>
>>> dir(g)
['__doc__', '__init__', '__module__', '__search__', '_pygoogle__setup_logging', 'display_results', 'filter', 'get_result_count', 'get_urls', 'hl', 'logger', 'pages', 'query', 'rsz', 'safe', 'search', 'search_page_wise']




you can also google something with pygoogle.py
# pwd
/root/Python_works/pygoogle-read-only
# ls
build  pygoogle.py  pygoogle.pyc  setup.py

# python pygoogle.py 'ubuntu linux'
[Ubuntu: The world's most popular free OS]
Official site; Commercially sponsored Debian-derived Linux distribution that
focuses on usability, a regular 6-month release cycle, and a commitment to at
least
http://www.ubuntu.com/

[Download Ubuntu | Ubuntu]
Get Ubuntu. Ubuntu is completely free to
download, use and share


# python pygoogle.py -hl en -v 'ubuntu fedora'
pygoogle DEBUG __search__| search: "ubuntu fedora" page# : 0
[Fedora vs Ubuntu - Difference and Comparison | Diffen]
Fedora vs Ubuntu comparison. While Ubuntu is the most popular Linux
distribution, Fedora is the fourth most popular. Fedora is based on Red Hat Linux
while
http://www.diffen.com/difference/Fedora_vs_Ubuntu

[Fedora vs. Ubuntu: Choosing the Right Linux Distribution - Udemy]
Nov 28, 2013 ... Learn about the major differences between Fedora and Ubuntu in this Fedora vs.
Ubuntu showdown
https://www.udemy.com/blog/fedora-vs-ubuntu/

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.