2017-02-22 1 views
1

私はこのURL「https://localhost/appserver/portal/api/1.0/apps」からJSONを取得する必要があり、CMD cURLを使用してこれを行うことができます。HTTPSサイトでJSONデータを取得するには、CMD cURLをExcel VBAコードに変換しますか?

curl 'https://<host>/appserver/portal/api/1.0/apps' 
-H 'Accept-Encoding: gzip, deflate, sdch, br' 
-H 'Accept-Language: en-US,en;q=0.8' 
-H 'Upgrade-Insecure-Requests: 1' 
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' 
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' 
-H 'Referer:  https://<host>/appserver/portal/login;jsessionid=A7DE3EB54B8E5151DA304D90DB48DF2E' 
-H 'Cookie: JSESSIONID=952E2B1F8E714BE302CA902469DB0781' 
-H 'Connection: keep-alive' 
-H 'Cache-Control: max-age=0' 
--compressed 
--insecure 

Excel VBAを使用してJSONを取得しようとしています。 HTTPSサイトでVBAを使用してJSONデータを取得する正しい方法は何ですか?

答えて

1

はこのような何かを試してみてください:

With CreateObject("MSXML2.ServerXMLHTTP") 
    .Open "GET", "https://<host>/appserver/portal/api/1.0/apps", False 
    .SetRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01" 
    .SetRequestHeader "Accept-Encoding", "gzip, deflate, sdch, br" 
    .SetRequestHeader "Accept-Language", "en-US,en;q=0.8" 
    .SetRequestHeader "Upgrade-Insecure-Requests", "1" 
    .SetRequestHeader "User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36" 
    .SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" 
    .SetRequestHeader "Referer", "https://<host>/appserver/portal/login;jsessionid=A7DE3EB54B8E5151DA304D90DB48DF2E" 
    .SetRequestHeader "Cookie", "JSESSIONID=952E2B1F8E714BE302CA902469DB0781" 
    .SetRequestHeader "Connection", "keep-alive" 
    .SetRequestHeader "Cache-Control", "max-age=0" 
    .Send 
    sHeaders = .getAllResponseHeaders 
    sContent = .responseText 
End With 

あなたが特定のウェブサイトでMSXML2.ServerXMLHTTPまたはMSXML2.XMLHTTPをしようとします。 MSXML2.XMLHTTPは、Cookieヘッダーを追加するかどうかに関係なく、保存されたCookieを送信します。

+0

ありがとうございました! –

関連する問題