使用Wikipedia API从页面中检索内容列表

时间:2016-11-24 13:33:33

标签: rest api wikipedia wikipedia-api

我想从这个wiki页面https://en.wikipedia.org/wiki/Outline_of_academic_disciplines中提取学科列表,我想知道如何使用Wikipedia API来实现它。

我尝试了以下内容:https://en.wikipedia.org/w/api.php?action=parse&page=List_of_action_films_of_the_2010s&contentmodel=wikitext&prop=wikitext&format=json

但这只检索文章的第一部分,我想检索内容部分,所以结果看起来像这样:

    decimal totalValue = 0;

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView row = e.Row.DataItem as DataRowView;
            totalValue += Convert.ToDecimal(row["tocht_id"]);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            if (totalValue == 100)
            {
                Button button = e.Row.FindControl("btnUpdatePCTD") as Button;
                button.Enabled = false;
            }

            Label label = e.Row.FindControl("grandTotalPCT") as Label;
            label.Text = string.Format("{0:N2}", GridView1.Rows.Count);
        }
    }

这可能使用维基百科API吗?

1 个答案:

答案 0 :(得分:1)

action=parse&format=json&page=Outline_of_academic_disciplines&prop=sections

"sections": [
        {
            "toclevel": 1,
            "level": "2",
            "line": "Arts",
            "number": "1",
            "index": "1",
            "fromtitle": "Outline_of_academic_disciplines",
            "byteoffset": 1241,
            "anchor": "Arts"
        },
        {
            "toclevel": 2,
            "level": "3",
            "line": "Performing arts",
            "number": "1.1",
            "index": "2",
            "fromtitle": "Outline_of_academic_disciplines",
            "byteoffset": 1279,
            "anchor": "Performing_arts"
        },
        ...