如何从命令行发布http请求

Ton*_*nyP 8 asp.net command-line http

嗨,我需要在dos命令行中向aspx页面发布请求..我该怎么做?

m.e*_*son 19

端口80上的telnet

例如:

telnet www.your-server.com/pageToTest.aspx 80
Run Code Online (Sandbox Code Playgroud)

然后键入 GET


Nei*_*eil 14

所有这些答案都需要安装 Windows 功能或其他程序。Powershell默认安装,可以从命令行运行

powershell -command "Invoke-WebRequest -Uri %url% -Method POST"
Run Code Online (Sandbox Code Playgroud)


小智 6

创建一个.vbs文件,其中包含:

' Set your settings
    strFileURL = "http://localhost/index.aspx"
    strHDLocation = "stream.temp"

' Fetch the file
    Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")

    objXMLHTTP.open "GET", strFileURL, false
    objXMLHTTP.send()

If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary

objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0    'Set the stream position to the start

Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation

objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if

Set objXMLHTTP = Nothing

' Delete the temp file
objFSO.DeleteFile strHDLocation

Set objFSO = Nothing
Run Code Online (Sandbox Code Playgroud)

然后执行使用:

cscript.exe scriptname.vbs
Run Code Online (Sandbox Code Playgroud)