Naver Korean Dictionary/English Dictionary Search Tool_v1.01_20220708

Distribute “Naver Korean Dictionary/English Dictionary Search Tool_v1.01_20220708” with one error corrected.

The outline of Naver Korean and English dictionary search tools and how to use them are summarized in the article below.

Overview of Naver Korean Dictionary/English Dictionary Search Tool

Today (2022-07-08) the following comments were posted.

https://prodtool.tistory.com/28#comment9159871

#ToDo: Review whether to change the comment link

네이버 국어사전/영어사전 검색 도구 오류 신고 댓글
Naver Korean Dictionary/English Dictionary Search Tool Report Error

Upon checking, I get the following error message:

네이버 국어사전/영어사전 검색 도구 오류 메시지
Naver Korean Dictionary/English Dictionary Search Tool Error Message

When I checked with Fiddler, the Response is empty.

Fiddler로 확인: No Response Body
Naver Korean Dictionary/English Dictionary Search Tool Fiddler: No Response Body

It seems that some condition has been added on the server. It doesn't seem to give a response when that condition isn't met.

If you search in a web browser, the response is normally received as json.

웹 브라우저 Fiddler로 확인: Response Body 있음
Check with web browser Fiddler: Response Body present

There is Referer in the Request header of a normal response.

Just in case, I added the Referer header. (modUtil.GetDataFromURL line 36)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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
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
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


works well!

The patched version of this error (Naver Korean Dictionary/English Dictionary Search Tool_v1.01_20220708) has been uploaded to github, and can be downloaded directly from the URL below.

https://github.com/DAToolset/ToolsForDataStandard/raw/main/Naver Korean Dictionary, English Dictionary Search Tool_v1.01_20220708.xlsm

For reference, I created a directory on github and uploaded the source code separately.

ToolsForDataStandard/src_Naver Korean dictionary, English dictionary search tool at main DAToolset/ToolsForDataStandard (github.com)


<< List of related articles >>

4 Responses

  1. Avatar photo 서희경 says:

    hello. In addition to the word extraction tool, the dictionary search tool is also being used well.
    But I discovered one thing.
    I searched by typing premium as premium as a typo, and it returned the result of premium.
    I was detecting typos along with attaching meaning... This is the result ^^;;

    When you search for the word in Naver Dictionary, it seems like it automatically converts the typo and gives you the result, but it would be nice to spit out only cases that match exactly... (Of course, there is an option called ‘exact match’ ^^;;)

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish