1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
if wscript.arguments.count < 3 then wscript.echo "用法: http {Get|Post} {path} {URL} [key1=value1 [key2=value2 ...]]" + vbcrlf + "注意: 如果要输入 "" 字符,请用 ^A (即 chr(1)) 代替" wscript.quit 0 end if dim xhr, ado dim method, path, url, param, i, j path = wscript.arguments(1) url = wscript.arguments(2) if url = replace(url, "://", "") then url = "http://" & url if wscript.arguments.count > 3 then i = 3 while i < wscript.arguments.count j = split(wscript.arguments(i),"=",2) if i <> 3 then param = param & "&" param = param & URLEncode(j(0)) if ubound(j) = 1 then param = param & "=" & URLEncode(replace(j(1),chr(1),"""")) i = i + 1 wend else param = "" end if set xhr = createobject("msxml2.xmlhttp") set ado = createobject("adodb.stream") on error resume next select case lcase(wscript.arguments(0)) case "get" xhr.open "Get", url & "?" & param, false xhr.send case "post" xhr.open "Post", url, false xhr.setrequestheader "Content-Type", "application/x-www-form-urlencoded" xhr.send param case else wscript.echo "用法: http {Get|Post} {URL} [key1=value1 [key2=value2 ...]]" wscript.quit 0 end select if err then 'wscript.echo err.description wscript.quit err.number elseif xhr.status < 200 or xhr.status > 299 then 'wscript.echo xhr.statustext wscript.quit xhr.status else ado.mode = 3 ado.type = 1 ado.open ado.write xhr.responsebody ado.savetofile path, 2 if err then 'wscript.echo err.description wscript.quit err.number end if ado.close end if on error goto 0 Function URLEncode(strURL) Dim I Dim tempStr For I = 1 To Len(strURL) If Asc(Mid(strURL, I, 1)) < 0 Then tempStr = "%" & Right(CStr(Hex(Asc(Mid(strURL, I, 1)))), 2) tempStr = "%" & Left(CStr(Hex(Asc(Mid(strURL, I, 1)))), Len(CStr(Hex(Asc(Mid(strURL, I, 1))))) - 2) & tempStr URLEncode = URLEncode & tempStr ElseIf (Asc(Mid(strURL, I, 1)) >= 65 And Asc(Mid(strURL, I, 1)) <= 90) Or (Asc(Mid(strURL, I, 1)) >= 97 And Asc(Mid(strURL, I, 1)) <= 122) Or (Asc(Mid(strURL, I, 1)) >= 48 And Asc(Mid(strURL, I, 1)) <= 57) Then URLEncode = URLEncode & Mid(strURL, I, 1) Else URLEncode = URLEncode & "%" & Hex(Asc(Mid(strURL, I, 1))) End If Next End Function |
https://github.com/gtr-0000/EasyChat-dl
发表回复