2010-11-25 111 views
6

嗨 我需要向dos命令行中的aspx页面发布请求。我该怎么做?如何从命令行发布http请求

+0

C#? VB?它可以做到 – hunter 2010-11-25 12:58:00

+0

当你说发布一个http请求时,你是否确实是指一个HTTP POST,或者你是指请求一个网页,就像任何ol浏览器会做的一样(HTTP GET)? – 2017-02-14 16:03:06

回答

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 

然后使用执行:

cscript.exe scriptname.vbs 
18

端口80

的telnet例如:

telnet www.your-server.com/pageToTest.aspx 80 

然后键入GET

+0

我得到`C:\ Windows \ system32> telnet 'telnet'不被识别为内部或外部命令, 可操作程序或批处理文件。' – CodyBugstein 2014-03-19 13:09:07

2

我有一些好运气卷曲http://curl.haxx.se/复制JSON发送到一个web服务。也许这也可以帮助你。

5

这可以使用wget完成。

1

Telnet是真的连接到远程Telnet服务器。实际上它(telnet服务器)在Windows 10中不存在,只存在于客户端。 你最好使用PowerShell。下面是一个例子访问OData服务: http://hodentekhelp.blogspot.com/2014/11/can-you-access-odata-with-powershell.html

而且审查的主题: https://social.technet.microsoft.com/Forums/en-US/035062dd-5052-4abe-bd9a-8714f4184806/there-is-no-telnet-server-in-windows-10-what-is-the-purpose-of-telnet-client?forum=win10itprogeneral