본문 바로가기

자료

[C#/vb.net] 네이버 맞춤법 검사 (WinHttp이용)

728x90

 

 

winhttp 참조 추가후 아래 소스 집어 넣으셔서 사용하시면됩니다~

  Private Function SpellerProxy(ByVal value As String) As String

        Dim URL As String, T As String

        URL = "https://m.search.naver.com/p/csearch/ocontent/util/SpellerProxy?"

        URL &= "_callback=jQuery1124027291531983561435_" & UNIX_TIME()

        URL &= "&q=" & UrlEncode(value)

        URL &= "&where=nexearch"

        URL &= "&color_blindness=0"

        URL &= "&_=" & UNIX_TIME()

        With CreateObject("WinHttp.WinHttpRequest.5.1")

            .Open("GET", URL)

            .SetRequestHeader("Host", "m.search.naver.com")

            .SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36")

            .SetRequestHeader("Accept", "*/*")

            .SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3")

            .SetRequestHeader("Referer", "https://search.naver.com/search.naver?query=%EB%A7%9E%EC%B6%A4%EB%B2%95%20%EA%B2%80%EC%82%AC")

            .SetRequestHeader("Connection", "keep-alive")

            If Len(Cookie) Then .SetRequestHeader("Cookie", Cookie)

            .Send()

            .WaitForResponse() : Application.DoEvents()

            T = .ResponseText

        End With

        T = T.Substring(T.IndexOf("{"))

        T = T.Substring(0, T.Length - 2)

        Dim O As Object = JsonConvert.DeserializeObject(T)

        T = O("message")("result")("notag_html")

        Do While T.IndexOf("<br><br>") > -1

            T = T.Replace("<br><br>", "<br>")

        Loop

        Return T.Replace("<br>", vbCrLf)

    End Function

 

 

 

728x90