70 likes | 182 Views
Project 1. Participation Page: http://tw.rpi.edu/web/Courses/WebSci/2011/ParticipationPage Direct Link to code snippet: http://tw.rpi.edu/media/latest/project1.zip Using the xgoogle library Dan Rotondo Web Science September 23 rd , 2011. What is xgoogle ?.
E N D
Project 1 Participation Page: http://tw.rpi.edu/web/Courses/WebSci/2011/ParticipationPage Direct Link to code snippet: http://tw.rpi.edu/media/latest/project1.zip Using the xgoogle library Dan Rotondo Web Science September 23rd, 2011
What is xgoogle? A Python library for Google Search Avoids having to use the Google API Less limitations on number of search queries http://www.catonmat.net/blog/python-library-for-google-search/
What does it do? Gets the Google website with your search results Use’s Beautiful Soup to parse the HTML code (http://www.crummy.com/software/BeautifulSoup/) Returns the results in text format (utf8)
Some of xgoogle’s methods/properties method get_results() – gets a page of results (a list of SearchResult objects) property num_results– number of search results found property results_per_page – sets/gets number of results per page property page– sets/gets the search page
How to use it SearchBase.py interfaces with xgoogle Must implement this class with any of your subclasses
Example Implementation import abc from SearchBase import SearchBase class YourClassName(SearchBase): [… your code here …] abc stands for Abstract Base Classes. If you’re interested in what they are: http://docs.python.org/library/abc.html
Things to note Do not download xgoogle from their website!!! (it’s out of date) Do use the website as a way to familiarize yourself with the library Go over the SportsSearch.py example Have Fun!