我要开发使用网上API,用GET和POST请求的程序,我想知道如何使程序内的请求(没有用户看到网页),然后将结果下载到程序,所以我可以解析它们

有帮助吗?

解决方案

您正在寻找的 WebRequest 类。本实施例中已被改编自MSDN文档:

Dim request As WebRequest = WebRequest.Create("http://www.example.com/example.html")
' Get the response.
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
' Get the stream containing content returned by the server.
Dim dataStream As Stream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)
' Read the content.
Dim responseFromServer As String = reader.ReadToEnd()
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top