Matthew Downey
Matthew Downey

Reputation: 259

How to use xgoogle

I am using the xgoogle library, whenever i ask it to get the number of search results it comes up with zero. (its not my code i copied it directly from the examples) any ideas?

Upvotes: 1

Views: 4226

Answers (1)

jcomeau_ictx
jcomeau_ictx

Reputation: 38422

This shows 1000000 results on my Debian system:


jcomeau@intrepid:/usr/src/xgoogle$ cat xg.py 
#!/usr/bin/python
from xgoogle.search import GoogleSearch, SearchError
try:
  gs = GoogleSearch("quick and dirty")
  gs.results_per_page = 50
  results = gs.get_results()
  print 'results', gs.num_results  # number of results
  for res in results:
    print res.title.encode("utf8")
    print res.desc.encode("utf8")
    print res.url.encode("utf8")
    print
except SearchError, e:
  print "Search failed: %s" % e

Upvotes: 1

Related Questions