我想开发一个使用在线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()