mca*_*dre 4 windows command-line curl
我正在编写一个跨平台的应用程序,教会人们如何使用命令行.我想向他们展示如何打印URL的HTML内容.通常情况下,我会使用curl此功能,但Windows不附带此程序,我不希望我的用户必须安装任何额外的程序.
有没有办法使用内置的MS-DOS命令模拟curl,也许发送一个VBScript片段wscript进行评估?
安装.net已安装,您可以将 c#与批处理文件组合以创建wget.cmd:
/*
@echo off && cls
if '%2'=='' (
echo usage: %0 url filename
goto :eof
)
set WinDirNet=%WinDir%\Microsoft.NET\Framework
IF EXIST "%WinDirNet%\v2.0.50727\csc.exe" set csc="%WinDirNet%\v2.0.50727\csc.exe"
IF EXIST "%WinDirNet%\v3.5\csc.exe" set csc="%WinDirNet%\v3.5\csc.exe"
IF EXIST "%WinDirNet%\v4.0.30319\csc.exe" set csc="%WinDirNet%\v4.0.30319\csc.exe"
%csc% /nologo /out:"%~0.exe" %0
"%~0.exe" "%1" "%2"
del "%~0.exe"
goto :eof
*/
using System;
using System.Net;
using System.IO;
class MyWget
{
static void Main(string[] args)
{
WebClient wc = new WebClient();
wc.DownloadFile(args[0],args[1]);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17116 次 |
| 最近记录: |