이 글은 새로운 블로그로 옮겼습니다. 5초후 자동으로 이동합니다.
▶ 새로운 블로그 주소: https://prodskill.com/
▶ 새로운 글 주소: https://prodskill.com/naver-korean-english-dictionary-search-tool-update-20220708/
한가지 오류를 수정한 "네이버 국어사전, 영어사전 검색 도구_v1.01_20220708"을 배포한다.
네이버 국어사전, 영어사전 검색 도구 사용 방법은 아래 글에 정리되어 있다.
네이버 국어사전, 영어사전 검색 도구 사용 방법 (tistory.com)
네이버 국어사전, 영어사전 검색 도구 사용 방법
네이버 국어사전과 영어사전을 반복하여 검색할 수 있는 매크로 도구의 다운로드 주소, 사용 방법에 대해 설명한다. 목차 1. 도구 개요 1.1. 필요성 네이버 국어사전과 영어사전을 검색하고 그 검
prodtool.tistory.com
오늘(2022-07-08) 다음과 같은 댓글이 달렸다.
https://prodtool.tistory.com/28#comment9159871
확인해 보니 다음과 같은 오류 메시지가 발생한다.
Fiddler로 확인해 보니, Response가 빈 상태이다.
서버에서 어떤 조건이 추가된 것으로 보인다. 그 조건을 만족하지 못할 때는 응답을 주지 않는 것 같다.
웹브라우저에서 조회하면 정상적으로 Response가 json으로 받아진다.
정상 응답을 받는 Request header에 Referer가 있다.
혹시나 하여 Referer header를 추가해 보았다.(modUtil.GetDataFromURL 36행)
Option Explicit
Function GetDataFromURL(strURL, strMethod, strPostData, Optional strCharSet = "UTF-8")
Dim lngTimeout
Dim strUserAgentString
Dim intSslErrorIgnoreFlags
Dim blnEnableRedirects
Dim blnEnableHttpsToHttpRedirects
Dim strHostOverride
Dim strLogin
Dim strPassword
Dim strResponseText
Dim objWinHttp
lngTimeout = 59000
strUserAgentString = "http_requester/0.1"
intSslErrorIgnoreFlags = 13056 ' 13056: ignore all err, 0: accept no err
blnEnableRedirects = True
blnEnableHttpsToHttpRedirects = True
strHostOverride = ""
strLogin = ""
strPassword = ""
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
'--------------------------------------------------------------------
'objWinHttp.SetProxy 2, "xxx.xxx.xxx.xxx:xxxx", "" 'Proxy를 사용하는 환경에서 설정
'--------------------------------------------------------------------
objWinHttp.SetTimeouts lngTimeout, lngTimeout, lngTimeout, lngTimeout
objWinHttp.Open strMethod, strURL
If strMethod = "POST" Then
objWinHttp.SetRequestHeader "Content-type", "application/x-www-form-urlencoded; charset=UTF-8"
Else
objWinHttp.SetRequestHeader "Content-type", "text/html; charset=euc-kr"
End If
If strHostOverride <> "" Then
objWinHttp.SetRequestHeader "Host", strHostOverride
End If
objWinHttp.SetRequestHeader "Referer", "https://ko.dict.naver.com/" '2022-07-08 추가
objWinHttp.Option(0) = strUserAgentString
objWinHttp.Option(4) = intSslErrorIgnoreFlags
objWinHttp.Option(6) = blnEnableRedirects
objWinHttp.Option(12) = blnEnableHttpsToHttpRedirects
If (strLogin <> "") And (strPassword <> "") Then
objWinHttp.SetCredentials strLogin, strPassword, 0
End If
On Error Resume Next
objWinHttp.Send (strPostData)
objWinHttp.WaitForResponse
If Err.Number = 0 Then
If objWinHttp.Status = "200" Then
'GetDataFromURL = objWinHttp.ResponseText
GetDataFromURL = BinaryToText(objWinHttp.ResponseBody, strCharSet)
Else
GetDataFromURL = "HTTP " & objWinHttp.Status & " " & _
objWinHttp.StatusText
End If
Else
GetDataFromURL = "Error " & Err.Number & " " & Err.Source & " " & _
Err.Description
End If
On Error GoTo 0
Set objWinHttp = Nothing
End Function
잘 동작한다!
이 오류를 패치한 버전을 github에 업로드 해두었고, 아래 URL로 바로 다운로드할 수 있다.
https://github.com/DAToolset/ToolsForDataStandard/raw/main/네이버 국어사전,영어사전 검색 도구_v1.01_20220708.xlsm
참고로, github에 디렉토리를 만들고 source code를 따로 올려놓았다.
ToolsForDataStandard/src_네이버 국어사전,영어사전 검색 도구 at main · DAToolset/ToolsForDataStandard (github.com)
GitHub - DAToolset/ToolsForDataStandard: Tools for Data Standardization (Data Standard Checker, Word Extractor, etc.)
Tools for Data Standardization (Data Standard Checker, Word Extractor, etc.) - GitHub - DAToolset/ToolsForDataStandard: Tools for Data Standardization (Data Standard Checker, Word Extractor, etc.)
github.com
제보해 주신 benif 님께 감사드립니다 ^^
'DA(Data Architecture) 도구 > 네이버 국어,영어사전 검색 도구' 카테고리의 다른 글
네이버 국어사전, 영어사전 검색 도구 동작 방식과 소스코드 설명 (8) | 2021.06.26 |
---|---|
네이버 국어사전, 영어사전 검색 도구 사용 방법 (20) | 2021.06.23 |
댓글