嗨,我需要在命令行中向aspx页面发布请求。我该如何做?
嗨,我需要在命令行中向aspx页面发布请求。我该如何做?
在80端口上使用telnet
例如:
telnet www.your-server.com/pageToTest.aspx 80
然后输入 GET
。
C:\Windows\system32>telnet 'telnet' 不是内部或外部命令,也不是可运行的程序或批处理文件。
- CodyBugsteinpowershell -command "Invoke-WebRequest -Uri %url% -Method POST"
' 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
这在Windows 10上运行正常
powershell -command "Invoke-WebRequest -UseBasicParsing -Method POST -Uri http://example.com/login -Body username=exampleuser'&'password=test"
Telnet主要用于连接远程Telnet服务器。实际上,它(Telnet服务器)在Windows 10中并不存在,只有客户端。
另一种方法是使用wget,这是一个常见的命令行工具(非常适用于下载)。在Windows上,您可以从此处获取http://gnuwin32.sourceforge.net/packages/wget.htm,而它已经是大多数Linux发行版的一部分。要使用它,只需执行以下操作:-
wget google.com
这将返回以下内容
--2018-03-20 16:31:39-- http://google.com/
Resolving google.com... 216.58.204.14
Connecting to google.com|216.58.204.14|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.google.co.uk/?gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg [following]
--2018-03-20 16:31:39-- http://www.google.co.uk/?gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg
Resolving www.google.co.uk... 216.58.201.3
Connecting to www.google.co.uk|216.58.201.3|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html@gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg'
[ <=> ] 12,441 --.-K/s in 0s
2018-03-20 16:31:40 (88.3 MB/s) - `index.html@gfe_rd=cr&dcr=0&ei=dzexWqybGof38Afo3ZmACg' saved [12441]