我尝试使用 xgoogle python 库来输入一个术语,它会返回有多少搜索结果。这是我的代码:
from xgoogle.search import GoogleSearch
word1 = 'aardvark'
word2 = 'ablaze'
words = word1,"",word2
gs = GoogleSearch(words)
num = gs.num_results
print num
这正在返回“回溯(最近一次通话最后一次):
File "F:\google whack\SearchTest.py", line 6, in <module>
num = gs.num_results
File "C:\Python27\xgoogle\search.py", line 89, in num_results
page = self._get_results_page()
File "C:\Python27\xgoogle\search.py", line 189, in _get_results_page
safe_url = [url % { 'query': urllib.quote_plus(self.query),
File "C:\Python27\lib\urllib.py", line 1245, in quote_plus
return quote(s, safe)
File "C:\Python27\lib\urllib.py", line 1236, in quote
if not s.rstrip(safe):
AttributeError: 'tuple' object has no attribute 'rstrip''
如果有人知道如何使它返回结果的数量,非常感谢您的帮助!!!谢谢!!!