【问题标题】:How to use xgoogle如何使用 xgoogle
【发布时间】:2011-03-08 03:27:57
【问题描述】:

我正在使用 xgoogle 库,每当我要求它获取搜索结果的数量时,它就会出现零。 (这不是我的代码,我直接从示例中复制了它)有什么想法吗?

【问题讨论】:

  • 他实际上已经接受了一些答案,我不知道为什么它显示为0%。

标签: python search xgoogle


【解决方案1】:

这在我的 Debian 系统上显示了 1000000 个结果:


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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    相关资源
    最近更新 更多