LoginSignup
0
1

More than 3 years have passed since last update.

URLからHtmlを取得する関数

Last updated at Posted at 2019-06-09
Option Explicit
Dim oHttp      As Object

Public Function GetHtmlsource(strURL As String)

  If oHttp Is Nothing Then
    Set oHttp = CreateObject("MSXML2.XMLHTTP")
  End If

  oHttp.Open "GET", strURL, False
  oHttp.setRequestHeader "If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT"
  oHttp.Send

  GetHtmlsource = oHttp.responseText

  If (oHttp.Status < 200 Or oHttp.Status >= 300) Then
    MsgBox "URL読み込みに失敗しました", vbExclamation + vbOKOnly, "Error!"
    GetHtmlsource = ""
  End If

End Function
0
1
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
0
1