我正在尝试使用 Wikipedia API 获取足球运动员的职业生涯总进球数和出场次数。我已经能够找到对给定信息的访问权限,但我不确定如何处理它所呈现的格式。
现在,我只是想通过控制台记录信息。
function fetchResults(searchQuery) {
const endpoint = `https://en.wikipedia.org/w/api.php?origin=*&action=parse&format=json&prop=sections&page=Jamie_Vardy§ion=15&prop=wikitext`;
console.log(endpoint);
fetch(endpoint)
.then(response => response.json())
.then(data => {
console.log(data.parse.wikitext);
})
.catch(() => console.log("ERROR"));
}
我在下图中突出显示了我希望获得的信息:
