简体   繁体   English

尝试在代码中使用 xgoogle 库时出错

[英]Have error when try to use xgoogle library in code

Have error with xgoogle library xgoogle 库有错误

When I tried to use this code:当我尝试使用此代码时:

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"))

I get this error:我收到此错误:

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

As mentioned on the library's website, xgoogle was only built as a "quick hack".正如图书馆网站上所提到的, xgoogle只是作为“快速破解”而构建的。 From what you mention, it looks like it's written in Python 2. You therefore will not be able to run it in Python 3, unless you rewrite it.根据您提到的,它看起来像是用 Python 2 编写的。因此,除非您重写它,否则您将无法在 Python 3 中运行它。

If you want to use Python 3, you'll likely have to find a library that supports it.如果您想使用 Python 3,您可能必须找到支持它的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使python库使用其他版本的boost-python - Make python library use another version of boost-python 停止Python代码没有错误 - Stop Python code without an error 当我多处理.pool.apply_async比我有处理器多次时会发生什么 - What happens when I multiprocessing.pool.apply_async more times than I have processors 当我尝试多处理时,会出现多个窗口 - When I try multiprocessing, multiple windows show up 在python中启动程序时如何使用标志/启动参数? - How to use flags/launch arguments when launching programs in python? (Django和PIL)编写图像文件时编码器错误-2 - (Django and PIL) encoder error -2 when writing image file 1)为什么会出现“无效语法”(代码中突出显示的行)? 2)错误解决后,为什么python只读取if语句? - 1)Why is there an "invalid syntax" (line highlighted in code)? 2) After the error is solved, why is only the if statement read by python? 无法获取窗口,中止。 运行从cython和cl编译的可执行文件时出现Kivy错误 - Unable to get a Window, abort. Kivy error when running an executable compiled from cython and cl 当rhc tail不显示错误时,如何在Openshift上调试Server Error 500? - How to debug Server Error 500 on Openshift, when rhc tail does not show errors? RuntimeError:找不到SDL2_ttf的任何库 - RuntimeError: could not find any library for SDL2_ttf
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM