vbscriptでmsxmlを利用してhttpアクセスする例です。
第一引数はアクセスするURL、第二引数はアクセスした内容を保存するファイル名です。

「Set OBJ_Http = WScript.CreateObject(“MSXML2.ServerXMLHTTP”)」の部分は、
「Set OBJ_Http = WScript.CreateObject(“Microsoft.XMLHTTP”)」としてもアクセス出来ます。

違いについてはMicrosoftのサポート情報を参照して下さい。
http://support.microsoft.com/kb/290761/ja

 


Option Explicit


  Dim OBJ_Args

  Set OBJ_Args = WScript.Arguments


  If OBJ_Args.Count <> 2 Then

    WScript.Echo "Usage: httpget URL Path"
    WScript.Quit 1


  Else

    HttpGet OBJ_Args(0),OBJ_Args(1)


  End If




Sub HttpGet(ByVal STR_URL, ByVal STR_Path)


  Const adTypeBinary = 1 'Binary
  Const adTypeText   = 2 'Text

  Const adSaveCreateNotExist  = 1
  Const adSaveCreateOverWrite = 2


  Dim OBJ_Http
  Dim OBJ_ADO

  Set OBJ_Http = WScript.CreateObject("MSXML2.ServerXMLHTTP")

  Call OBJ_Http.Open("GET", STR_URL, False)

  If Err.Number <> 0 Then

      WScript.Echo "エラー:" & Err.Description
      WScript.Quit 1

  End If

  OBJ_Http.Send

  If Err.Number <> 0 Then

    WScript.Echo "エラー:" & Err.Description
    WScript.Quit 1

  End If

  If OBJ_Http.status <> 200 Then

    WScript.Echo "Return Coad:" & OBJ_Http.status
    WScript.Quit 1

  End If


  Set OBJ_ADO = WScript.CreateObject("ADODB.Stream")
  
  OBJ_ADO.Type = adTypeBinary
  OBJ_ADO.Open
  OBJ_ADO.Position = 0

  OBJ_ADO.Write OBJ_Http.responseBody
  OBJ_ADO.SaveToFile STR_Path, adSaveCreateNotExist
  OBJ_ADO.Close

  Set OBJ_Http = Nothing
  Set OBJ_ADO  = Nothing


End Sub

16 Comments

  1. Speedpaste bestellen says:

    … [Trackback]

    […] Find More on to that Topic: dragon-ark.com/archives/564 […]

  2. 3d drawing app says:

    … [Trackback]

    […] Read More on that Topic: dragon-ark.com/archives/564 […]

  3. exchange online fiyat says:

    … [Trackback]

    […] Read More to that Topic: dragon-ark.com/archives/564 […]

  4. hp sunucu servisi says:

    … [Trackback]

    […] There you can find 5705 additional Info on that Topic: dragon-ark.com/archives/564 […]

  5. microsoft exchange online plan 1 says:

    … [Trackback]

    […] Find More to that Topic: dragon-ark.com/archives/564 […]

  6. internet teknik servis says:

    … [Trackback]

    […] Here you can find 92036 more Info to that Topic: dragon-ark.com/archives/564 […]

  7. lenovo servis says:

    … [Trackback]

    […] Read More Information here on that Topic: dragon-ark.com/archives/564 […]

Leave a Reply