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
날짜: 2004-09-08 14:06:37,
조회수: 3682 |