所以,我正在尝试编译一个数据库,其中包含雅虎答案中包含某个词的所有问题。我目前正在使用我编写的以下脚本来执行此操作,使用Pynswers包装类来调用yahooapi
from Answers import Answers
app = Answers()
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('sheet 1')
app.appid = '...'
questions = app.questionSearch({'query':'tornado',})
#Write all column headings
sheet.write(0,0, 'Question')
sheet.write(0,1,'Answer')
sheet.write(0,2, 'Date')
sheet.write(0,3,'Number of Answers')
for i, value in enumerate(questions):
content = value['Content'].strip()
chosenAnswer = value['ChosenAnswer'].strip()
date = value['Date'].strip()
numAnswers = value['NumAnswers'].strip()
#Write values into respect columns, (row, column)
sheet.write(i+1,0,content)
sheet.write(i+1,1,chosenAnswer)
sheet.write(i+1,2,date)
sheet.write(i+1,3,numAnswers)
wbk.save('C://test.xls')
问题是,我只能从这个问题中得到大约10个答案,而且我无法找到一个方法来扩展我得到的问题的范围。有什么想法吗?在
Pynswers似乎是Yahoo API itself的一个非常松散的包装。API文档显示在请求中使用“开始”和“结果”字段:
所以,也许你可以做以下事情:
编辑
此外,关于“利率限制”,Yahoo states in regard to their API(此部分摄于2013年3月7日):
显然,您需要小心处理代码,以确保在不超过速率限制的情况下获得所需的信息。因此,得到“全部”答案可能并不实际。在
相关问题 更多 >
编程相关推荐