【问题标题】:Have error when try to use xgoogle library in code尝试在代码中使用 xgoogle 库时出错
【发布时间】:2019-10-22 12:43:44
【问题描述】:

xgoogle 库出错

当我尝试使用此代码时:

from xgoogle.search import GoogleSearch, SearchError
try:
  gs = GoogleSearch("quick")
  gs.results_per_page = 50
  results = gs.get_results()
  for res in results:
    print (res.title.encode("utf8"))
    print (res.desc.encode("utf8"))
    print (res.url.encode("utf8"))

我收到此错误:

Traceback (most recent call last):
  File "C:/Users/s.sorokin/PycharmProjects/hh.ru/xgoogle.py", line 1, in <module>
    from xgoogle.search import GoogleSearch, SearchError
  File "C:\Users\s.sorokin\PycharmProjects\hh.ru\xgoogle\search.py", line 124
    raise SearchError, "Wrong parameter to first_indexed_in_previous: %s" % (str(interval))
                     ^
SyntaxError: invalid syntax

【问题讨论】:

  • 好的,当我尝试使用 python 2.7 时,代码工作正常谁现在我如何在 3.7 版上使用这个库?

标签: python-3.3


【解决方案1】:

正如图书馆网站上所述,xgoogle 只是作为“快速破解”而构建的。从您提到的情况来看,它看起来像是用 Python 2 编写的。因此,除非您重写它,否则您将无法在 Python 3 中运行它。

如果您想使用 Python 3,您可能必须找到支持它的库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-06
    相关资源
    最近更新 更多