我想开发一个使用在线API的程序,有GET和POST请求,我想知道如何在程序中发出请求(没有用户看到网页),然后将结果下载到程序,所以我可以解析它们
答案 0 :(得分:3)
您正在寻找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()