{ "info": { "author": "Holger Berndt", "author_email": "peter@catonmat.net", "bugtrack_url": null, "classifiers": [], "description": "", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/pkrumins/xgoogle/blob/master/setup.py", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "This is a Google library called 'xgoogle'. Current version is 1.4.\r\n\r\nIt's written by Peteris Krumins (peter@catonmat.net).\r\nHis blog is at http://www.catonmat.net -- good coders code, great reuse.\r\n\r\nThe code is licensed under MIT license.\r\n\r\n--------------------------------------------------------------------------\r\n\r\nAt the moment it contains:\r\n * Google Search module xgoogle/search.py.\r\n http://www.catonmat.net/blog/python-library-for-google-search/\r\n\r\n * Google Sponsored Links Search module xgoogle/sponsoredlinks.py\r\n http://www.catonmat.net/blog/python-library-for-google-sponsored-links-search/\r\n\r\n * Google Sets module xgoogle/googlesets.py\r\n http://www.catonmat.net/blog/python-library-for-google-sets/\r\n\r\n * Google Translate module xgoogle/translate.py\r\n http://www.catonmat.net/blog/python-library-for-google-translate/\r\n\r\n--------------------------------------------------------------------------\r\n\r\nHere is an example usage of Google Search module:\r\n\r\n >>> from xgoogle.search import GoogleSearch\r\n >>> gs = GoogleSearch(\"catonmat\")\r\n >>> gs.results_per_page = 25\r\n >>> results = gs.get_results()\r\n >>> for res in results:\r\n ... print res.title.encode('utf8')\r\n ... \r\n\r\n output:\r\n\r\n good coders code, great reuse\r\n MIT's Introduction to Algorithms, Lectures 1 and 2: Analysis of ...\r\n catonmat - Google Code\r\n ...\r\n\r\nThe GoogleSearch object has several public methods and properties:\r\n\r\n method get_results() - gets a page of results, returning a list of SearchResult objects.\r\n property num_results - returns number of search results found.\r\n property results_per_page - sets/gets the number of results to get per page.\r\n property page - sets/gets the search page.\r\n\r\nA SearchResult object has three attributes -- \"title\", \"desc\", and \"url\".\r\nThey are Unicode strings, so do a proper encoding before outputting them.\r\n\r\n--------------------------------------------------------------------------\r\n\r\nHere is an example usage of Google Sponsored Links Search module:\r\n\r\n >>> from xgoogle.sponsoredlinks import SponsoredLinks, SLError\r\n >>> sl = SponsoredLinks(\"video software\")\r\n >>> sl.results_per_page = 100\r\n >>> results = sl.get_results()\r\n >>> for result in results:\r\n ... print result.title.encode('utf8')\r\n ...\r\n\r\n output:\r\n\r\n Photoshop Video Software\r\n Video Poker Software\r\n DVD/Video Rental Software\r\n ...\r\n\r\nThe SponsoredLinks object has several public methods and properties:\r\n\r\n method get_results() - gets a page of results, returning a list of SearchResult objects.\r\n property num_results - returns number of search results found.\r\n property results_per_page - sets/gets the number of results to get per page.\r\n\r\nA SponsoredLink object has four attributes -- \"title\", \"desc\", \"url\", and \"display_url\".\r\nThey are Unicode strings, don't forget to use a proper encoding before outputting them.\r\n\r\n--------------------------------------------------------------------------\r\n\r\nHere is an example usage of Google Sets module:\r\n\r\n >>> from xgoogle.googlesets import GoogleSets\r\n >>> gs = GoogleSets(['red', 'yellow'])\r\n >>> results = gs.get_results()\r\n >>> print len(results)\r\n >>> for r in results:\r\n ... print r.encode('utf8')\r\n ... \r\n\r\n output:\r\n\r\n red\r\n yellow\r\n blue\r\n white\r\n ...\r\n\r\nThe GoogleSets object has only get_results(set_type) public method. The default value\r\nfor set_type is SMALL_SET, which makes it return 15 related items or fewer.\r\nUse LARGE_SET to get more than 15 items. This get_results() method returns a list of\r\nrelated items that are represented as unicode strings.\r\nDon't forget to do the proper encoding when outputting these strings!\r\n\r\nHere is an example showing differences between SMALL_SET and LARGE_SET:\r\n\r\n >>> from xgoogle.googlesets import GoogleSets, LARGE_SET, SMALL_SET\r\n >>> gs = GoogleSets(['python', 'perl'])\r\n >>> results_small = gs.get_results() # SMALL_SET by default\r\n >>> len(results_small)\r\n 11\r\n >>> results_small\r\n [u'python', u'perl', u'php', u'ruby', u'java', u'javascript', u'c++', u'c',\r\n u'cgi', u'tcl', u'c#']\r\n >>>\r\n >>> results_large = gs.get_results(LARGE_SET)\r\n >>> len(results_large)\r\n 46\r\n >>> results_large\r\n [u'perl', u'python', u'java', u'c++', u'php', u'c', u'c#', u'javascript',\r\n u'howto', u'wiki', u'raid', u'dd', u'linux', u'ruby', u'language', u'xml',\r\n u'sgml', u'svn', u'kernel', ...]\r\n\r\n\r\n--------------------------------------------------------------------------\r\n\r\nHere is an example usage of Google Translate module:\r\n\r\n >>> from xgoogle.translate import Translator\r\n >>>\r\n >>> translate = Translator().translate\r\n >>> print translate(\"Mani sauc P\u0113teris\", lang_to=\"ru\").encode('utf-8')\r\n \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041f\u0435\u0442\u0440\r\n >>> print translate(\"Mani sauc P\u0113teris\", lang_to=\"en\")\r\n My name is Peter\r\n >>> print translate(\"\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u041f\u0435\u0442\u0440\")\r\n My name is Peter\r\n\r\nThe \"translate\" function takes three arguments - \"message\", \"lang_from\" and \"lang_to\".\r\nIf \"lang_from\" is not given, Google's translation service auto-detects it.\r\nIf \"lang_to\" is not given, it defaults to \"en\" (English).\r\n\r\nIn case of an error the \"translate\" function throws \"TranslationError\" exception.\r\nMake sure to wrap your code in try/except block to catch it:\r\n\r\n >>> from xgoogle.translate import Translator, TranslationError\r\n >>>\r\n >>> try: \r\n >>> translate = Translator().translate\r\n >>> print translate(\"\")\r\n >>> except TranslationError, e:\r\n >>> print e\r\n\r\n Failed translating: invalid text \r\n\r\n\r\nThe Google Translate module also provides \"LanguageDetector\" class that can be used\r\nto detect the language of the text.\r\n\r\nHere is an example usage of LanguageDetector:\r\n\r\n >>> from xgoogle.translate import LanguageDetector, DetectionError\r\n >>>\r\n >>> detect = LanguageDetector().detect\r\n >>> english = detect(\"This is a wonderful library.\")\r\n >>> english.lang_code\r\n 'en'\r\n >>> english.lang\r\n 'English'\r\n >>> english.confidence\r\n 0.28078437000000001\r\n >>> english.is_reliable\r\n True\r\n\r\nThe \"DetectionError\" may get raised if the detection failed.\r\n\r\n\r\n--------------------------------------------------------------------------\r\n\r\n\r\nVersion history:\r\n\r\nv1.0: * initial release, xgoogle library contains just the Google Search.\r\nv1.1: * added Google Sponsored Links Search.\r\n * fixed a bug in browser.py that might have thrown an unexpected exception.\r\nv1.2: * added Google Sets module\r\nv1.3: * added Google Translate module\r\n * fixed a bug in browser.py when KeyboardInterrupt did not get propagated.\r\n\r\n--------------------------------------------------------------------------\r\n\r\nThat's it. Have fun! :)\r\n\r\n\r\nSincerely,\r\nPeteris Krumins\r\nhttp://www.catonmat.net", "maintainer": "", "maintainer_email": "peter@catonmat.net", "name": "xgoogle", "package_url": "https://pypi.org/project/xgoogle/", "platform": "", "project_url": "https://pypi.org/project/xgoogle/", "project_urls": { "Download": "https://github.com/pkrumins/xgoogle/blob/master/setup.py" }, "release_url": "https://pypi.org/project/xgoogle/1/", "requires_dist": null, "requires_python": null, "summary": "", "version": "1" }, "last_serial": 453085, "releases": { "1": [] }, "urls": [] }