python-3.3 - 尝试在代码中使用 xgoogle 库时出错
问题描述
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
解决方案
正如图书馆网站上所提到的,xgoogle
它只是作为“快速破解”而构建的。从您提到的内容来看,它看起来像是用 Python 2 编写的。因此,除非您重写它,否则您将无法在 Python 3 中运行它。
如果您想使用 Python 3,您可能必须找到支持它的库。
推荐阅读
- java - 如何在分区中转换行
- visual-studio - SSRS - 根据字符串更改背景颜色
- java - Java:不导入 java.util 的随机排列
- php - Laravel 如何在不隐式使用 PHP 中方法的 static 关键字的情况下,动态地静态调用类方法?
- reporting-services - 在 ssrs /report builder 中使用级联参数的自定义值
- html - html 元素在 CSS 显示 flex 属性中拉伸
- python - ModuleNotFoundError:没有名为错误python 3.8.2的模块
- swift - 在 iOS 中导航回特定屏幕时出现问题
- php - PHP - 只声明一次变量
- sql-server - 如果找不到多个实例,则强制 CharIndex 仅返回 0?