2011-11-06 149 views
1

我使用wikitools包解析维基百科。我只是从文档中复制这个例子。但它不工作。当我运行这个代码。我得到以下错误。 Invalid JSON,trying requesting again。你能帮我么 ?谢谢wikitools解析错误

from wikitools import wiki 
from wikitools import api 
# create a Wiki object 
site = wiki.Wiki("http://my.wikisite.org/w/api.php") 
# define the params for the query 
params = {'action':'query', 'titles':'Papori'} 
# create the request object 
request = api.APIRequest(site, params) 
# query the API 
result = request.query() 
+0

是那整个代码?当我运行它时,我得到'TypeError:序列项目0:期望的字符串,int在5秒内再次尝试请求 TypeError:序列项目0:期望的字符串,int在10秒内再次尝试请求' - 不是你描述的错误。 – jedwards

回答

3

"http://my.wikisite.org/w/api.php"只是一个例子,该域下没有MediaWiki。试用"http://en.wikipedia.org/w/api.php",在英文维基百科中进行搜索。