Module google
[hide private]
[frames] | no frames]

Module google

source code

Functions [hide private]
str
get_page(url)
Request the given URL and return the response page, using the cookie jar.
source code
 
filter_result(link) source code
generator
search(query, tld='com', lang='en', num=10, start=0, stop=None, pause=2.0)
Search the given query string using Google.
source code
Variables [hide private]
  url_home = 'http://www.google.%(tld)s/'
  url_search = 'http://www.google.%(tld)s/search?hl=%(lang)s&q=%...
  url_next_page = 'http://www.google.%(tld)s/search?hl=%(lang)s&...
  url_search_num = 'http://www.google.%(tld)s/search?hl=%(lang)s...
  url_next_page_num = 'http://www.google.%(tld)s/search?hl=%(lan...
  home_folder = 'C:\\Users\\Mario'
  cookie_jar = <_LWPCookieJar.LWPCookieJar[Cookie(version=0, nam...
  __package__ = None
Function Details [hide private]

get_page(url)

source code 

Request the given URL and return the response page, using the cookie jar.

Parameters:
  • url (str) - URL to retrieve.
Returns: str
Web page retrieved for the given URL.
Raises:
  • IOError - An exception is raised on error.
  • urllib2.URLError - An exception is raised on error.
  • urllib2.HTTPError - An exception is raised on error.

search(query, tld='com', lang='en', num=10, start=0, stop=None, pause=2.0)

source code 

Search the given query string using Google.

Parameters:
  • query (str) - Query string. Must NOT be url-encoded.
  • tld (str) - Top level domain.
  • lang (str) - Languaje.
  • num (int) - Number of results per page.
  • start (int) - First result to retrieve.
  • stop (int) - Last result to retrieve. Use None to keep searching forever.
  • pause (float) - Lapse to wait between HTTP requests. A lapse too long will make the search slow, but a lapse too short may cause Google to block your IP. Your mileage may vary!
Returns: generator
Generator (iterator) that yields found URLs. If the stop parameter is None the iterator will loop forever.

Variables Details [hide private]

url_search

Value:
'http://www.google.%(tld)s/search?hl=%(lang)s&q=%(query)s&btnG=Google+\
Search'

url_next_page

Value:
'http://www.google.%(tld)s/search?hl=%(lang)s&q=%(query)s&start=%(star\
t)d'

url_search_num

Value:
'http://www.google.%(tld)s/search?hl=%(lang)s&q=%(query)s&num=%(num)d&\
btnG=Google+Search'

url_next_page_num

Value:
'http://www.google.%(tld)s/search?hl=%(lang)s&q=%(query)s&num=%(num)d&\
start=%(start)d'

cookie_jar

Value:
<_LWPCookieJar.LWPCookieJar[Cookie(version=0, name='NID', value='67=i2\
iDRtkObu421VsoDCw5mWh7rx8tkGE-NMFqFeT6R2OCqQUl5SUVJsOK2kxPbtV_2XhWeFJl\
ttwTd1cOdUSC3bJi6IAtTHZ2udMksVcuD5EYC8P0zwhLa-cVr7-A2L-s', port=None, \
port_specified=False, domain='.google.com', domain_specified=True, dom\
ain_initial_dot=True, path='/', path_specified=True, secure=False, exp\
ires=1383392787, discard=False, comment=None, comment_url=None, rest={\
'HttpOnly': 'None'}, rfc2109=False), Cookie(version=0, name='PREF', va\
lue='ID=14d91554e4da5c30:U=7a1152c08e1e5a95:FF=0:TM=1367581587:LM=1367\
...