我尝试使用xgoogle python函数库来输入一个术语,并且它返回了多少个搜索结果。这里是我的代码:xgoogle函数库因AttributeError失败
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''
如果有人知道如何使这个返回结果的数量,帮助是非常感谢! !谢谢!!!
或gs = GoogleSearch(''.join(word1,word2,word3)) – 2011-03-08 03:14:17