我想从
中保存“title”值https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&titles=usa&redirects=true
我使用此代码但不起作用:
string fileDownload;
using (WebClient client = new WebClient())
{
fileDownload = client.DownloadString("https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&titles=usa&redirects=true");
}
JObject sa = JObject.Parse(fileDownload);
string sq = sa["query"]["pages"][0]["title"].ToString();
我在[0]
之后使用["pages"]
,因为其他网页的pageid更改。
答案 0 :(得分:2)
尝试以下
string sq = sa["query"]["pages"].First.First["title"].ToString();