vb6.0/vba [vb6.0/vba] WinHttp를 이용하여 443포트 통신으로 위키백과(ko.wikipedia.org) 에서 특정 키워드…
페이지 정보
본문
[vb6.0/vba] WinHttp를 이용하여 443포트 통신으로 위키백과(ko.wikipedia.org) 에서 특정 키워드로 검색하여 특정 단어가 있는지 체크하기
Function program1472(ByVal SearchString As String, ByVal Words As String)
Dim URL As String, T As String, Cookie As String
With CreateObject("MSXML2.XMLHTTP.6.0")
.Open "GET", URL
.SetRequestHeader "Host", "ko.wikipedia.org"
.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0"
.SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
.SetRequestHeader "Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3"
.SetRequestHeader "Connection", "keep-alive"
If Len(Cookie) Then .SetRequestHeader "Cookie", Cookie
.SetRequestHeader "Upgrade-Insecure-Requests", "1"
.SetRequestHeader "TE", "Trailers"
.Send
T = .ResponseText
End With
program1472 = InStr(T, Words) > 0
End Function
Public Function URLEncode(ByVal StringVal As String, Optional SpaceAsPlus As Boolean = False) As String
Dim bytes() As Byte, b As Byte, i As Integer, space As String
If SpaceAsPlus Then space = "+" Else space = "%20"
If Len(StringVal) > 0 Then
With CreateObject("ADODB.Stream")
.Mode = 3 '// adModeReadWrite
.Type = 2 '// adTypeText
.Charset = "UTF-8"
.Open
.WriteText StringVal
.Position = 0
.Type = 1 '// adTypeBinary
.Position = 3 ' skip BOM
bytes = .Read
End With
ReDim result(UBound(bytes)) As String
For i = UBound(bytes) To 0 Step -1
b = bytes(i)
Select Case b
Case 97 To 122, 65 To 90, 48 To 57, 45, 46, 95, 126
result(i) = Chr(b)
Case 32
result(i) = space
Case 0 To 15
result(i) = "%0" & Hex(b)
Case Else
result(i) = "%" & Hex(b)
End Select
Next i
URLEncode = Join(result, "")
End If
End Function
- 이전글[vb6.0/vba] VBScript 를 이용한 URL Encode/Decode 20.06.30
- 다음글[vb6.0/vba] ADODB.Stream을 이용한 EUC-KR URL Encode 20.05.23
댓글목록
등록된 댓글이 없습니다.