1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ブラウザ以外からHTTPリクエストを送ってみた時のメモ

Posted at

タイトル通りです。

参考にさせていただいたのは↓

今回はとりあえずUA情報が取りたかっただけなので、全てHEADメソッドを使用。

Excelの場合(1)

Sub onClick()
    Dim httpReq As XMLHTTP60
    Set httpReq = New XMLHTTP60
    Dim uri As String
    uri = "http://localhost:3000/"
    Call httpReq.Open("HEAD", uri, False)
    Call httpReq.Send
    Do While httpReq.readyState < 4
        DoEvents
    Loop
    Set httpReq = Nothing
End Sub

Excelの場合(2)

Sub onClick_2()
    Dim winHttp As Object
    Set winHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    Dim uri As String
    uri = "http://localhost:3000/"

    winHttp.Open "HEAD", uri
    winHttp.Send
End Sub

powershellの場合

$uri = 'http://localhost:3000/'
$response = Invoke-WebRequest -Uri $uri -UseBasicParsing -Method HEAD

おわりに

頑張れば負荷テストなどに応用できるかも、と思いつつ、
そこまでの余力はなさそうなのでここまで。
業務からは外れるけどスクレイピングとかも出来たら楽しいかも……

VBAなら一度結構がっつり書いてたことがあるので、やるならVBAかなあ
powershellすらすら書けるようになりたい……

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?