안규 공부방

ACTIVE SERVER PAGE > Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") - 네이버 검색정보 읽어오기 예제

등록일 : 2019-10-30 16:41 조회수 : 93,315


아래 소스는 네이버 검색정보 읽어오는 예제 입니다.
 

  <%
  Response.Charset="euc-kr" 'asp페이지 charset설정
  keyword = "love"

  URL = "https://endic.naver.com/search.nhn?sLn=kr&searchOption=all&query="&keyword

  set winhttp = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") 
  winhttp.SetTimeouts 10 * 1000, 30 * 1000, 30 * 1000, 30 * 1000
  winhttp.Open "GET",URL, False 
  winhttp.SetRequestHeader "User-Agent", "ASP/3.0"
  winhttp.SetRequestHeader "Host", "endic.naver.com"
  winhttp.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0"
  winhttp.SetRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
  winhttp.SetRequestHeader "Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3"
  winhttp.SetRequestHeader "Connection", "keep-alive"
  winhttp.SetRequestHeader "Upgrade-Insecure-Requests", "1"
  winhttp.SetRequestHeader "TE", "Trailers"
  winhttp.Send
  T = winhttp.ResponseText

  response.write tagFree(T)
  

'정규식을 이용한 HTML 태그제거
  Function tagFree(str_)
		Dim temp_Str
		If Len(str_) > 0 Then
			Set crabz = New Regexp
			crabz.Pattern = "<[^>]+>"
			crabz.Global = True
			temp_Str = crabz.Replace(str_,"")
		End if
		tagFree = temp_Str	
  End  Function

 


%>






 
※ 혹시 도움이 되셨다면 댓글에 한마디 남겨주세요!
작성자   비밀번호
자동글 방지     (자동글 방지 기능입니다.)
내용   댓글달기 
이메일 문의 : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.