2

我正在尝试使用从维基百科获取数据Special:Export

以下是我的标记,我无法理解为什么它没有进入 while 循环?我没有得到任何错误。请帮助。

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim webRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create("http://en.wikipedia.org/wiki/Special:Export/Train"), HttpWebRequest)
        webRequest.Credentials = System.Net.CredentialCache.DefaultCredentials
        webRequest.Accept = "text/xml"
        webRequest.UserAgent = "foo/bar"
        Dim webResponse As System.Net.HttpWebResponse = CType(webRequest.GetResponse, HttpWebResponse)
        Dim responseStream As System.IO.Stream = webResponse.GetResponseStream
        Dim reader As System.Xml.XmlTextReader = New XmlTextReader(responseStream)
        Dim NS As String = "http://www.mediawiki.org/xml/export-0.4/"
        Dim doc As XPathDocument = New XPathDocument(reader)
        reader.Close()
        webResponse.Close()
        Dim myXPathNavigator As XPathNavigator = doc.CreateNavigator
        Dim nodesText As XPathNodeIterator = myXPathNavigator.SelectDescendants("text", NS, False)

        While nodesText.MoveNext
            Response.Write((nodesText.Current.InnerXml + " "))
        End While
    End Sub
4

1 回答 1

0

特别:导出应该是 POST'ed。请参阅特殊:出口手册

但是,您真的不应该这样做。请使用您选择的语言的 Web API 客户端库并访问导出模块

于 2015-04-27T22:18:04.580 回答