2011-11-06 147 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",在英文維基百科中進行搜索。