리모트사이트의 페이지 긁어오기 투

asp에서는 php와 달리 리모트사이트의 페이지를 긁어오기 위해서 프리컴포넌트를 썼었는데 부하에 약한 단점이 있었다.

디폴트로 제공하는 MSXML2.ServerXMLHTTP 이걸쓰면 바이너리로 읽어와
한글에 문제가 있었는데..
아스키코드를 변환하는 함수를 통해(뉴스그룹에서 참조)
간단히 구현해 보았다.
유용하게 쓰시길..

<%
url = "http://cobbi.hani.co.kr/section-homepage/news/03/family_top.txt"
call getRemoteFile(url)

sub getRemoteFile(url)

Set oXMLHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

oXMLHttp.open "GET", url, false
oXMLHttp.send()

sXML=oXMLHttp.responseBody

sXML = getConvAscii(sXML)

response.write sXML

set oXMLHttp = nothing
end sub

Function getConvAscii(value)
Dim strV, i, s, intChr, ichr1, ichr2, strS
s = LenB(value) : strV = "" :
For i = 1 to s
intChr = AscB(MidB(value, i, 2))
if intChr > 128 then
ichr1 = intChr
i = i + 1
ichr2 = AscB(MidB(value, i, 2))
strS = “&H” & Hex(ichr1) & Hex(ichr2)
strV = strV & Chr(strS)
Else
strV = strV & Chr(intChr)
End If
Next
getConvAscii = strV
End Function

%>

테스트 페이지 –> http://bbs.hani.co.kr/aninstory/xml_test.asp

Comments

Powered by Facebook Comments

댓글 남기기

당신의 이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.

*

다음의 HTML 태그와 속성을 사용할 수 있습니다: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>