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.
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’ ^^;;)
Thank you for your good comments.
When I checked the Naver Dictionary search result JSON data, when the entered word (A) and the word in the search result (B) are different, there is an item to manage the two values separately.
We will soon add a feature so that you can check if the word you entered (A) is different from the word in the search results (B).
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’ ^^;;)
Thank you for your good comments.
When I checked the Naver Dictionary search result JSON data, when the entered word (A) and the word in the search result (B) are different, there is an item to manage the two values separately.
We will soon add a feature so that you can check if the word you entered (A) is different from the word in the search results (B).
Oh oh!! I'm glad it's an item that can be changed!! I look forward to it. Thank you.
I patched the feature and wrote an article.
https://prodskill.com/ko/naver-korean-english-dictionary-search-tool-update-20240201/
Please refer to the contents.