티스토리 뷰
'// ASP 페이지를 읽어서 html 파일로 생성 '// CALL asp2htm(페이지 URL, 저장할 파일[전체 경로포함]) Function asp2htm(url, saveDir) Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1") 'objWinHttp.Open "GET", "실행할 asp파일경로(예.http://www.aaa.com/index.asp)", false objWinHttp.Open "GET", url, false objWinHttp.Send() returnMsg = fnStreamBinaryToString(objWinHttp.ResponseBody, "euc-kr") set objWinHttp = nothing If returnMsg = "" Then asp2htm = "0,Error" Exit Function End If dim objFso set objFso=server.CreateObject("Scripting.Filesystemobject") set objFiler=objFso.CreateTextFile(saveDir, true) set objFiler=nothing dim objFile set objFile=objFSO.OpenTextFile(saveDir,8,true) objFile.WriteLine returnMsg objFile.close set objFso=nothing asp2htm = "1,Success" End Function '// asp2htm Sub Function Function fnStreamBinaryToString(Binary, CharSet) Const adTypeText = 2 Const adTypeBinary = 1 '//Create Stream object Dim BinaryStream 'As New Stream Set BinaryStream = CreateObject("ADODB.Stream") '//Specify stream type - we want To save text/string data. BinaryStream.Type = adTypeBinary '//Open the stream And write text/string data To the object BinaryStream.Open BinaryStream.Write Binary '//Change stream type To binary BinaryStream.Position = 0 BinaryStream.Type = adTypeText '//Specify charset For the source text (unicode) data. If Len(CharSet) > 0 Then BinaryStream.CharSet = CharSet Else BinaryStream.CharSet = "us-ascii" End If '//Open the stream And get binary data from the object fnStreamBinaryToString = BinaryStream.ReadText End Function '// URL로부터 파일을 다운받아 로컬에 저장 Function SaveFileFromUrl(Url, saveFullDir) dim objXMLHTTP, objADOStream, objFSO Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0") objXMLHTTP.open "GET", Url, false objXMLHTTP.send() If objXMLHTTP.Status = 200 Then Set objADOStream = CreateObject("ADODB.Stream") objADOStream.Open objADOStream.Type = 1 'adTypeBinary objADOStream.Write objXMLHTTP.ResponseBody objADOStream.Position = 0 'Set the stream position to the start Set objFSO = Createobject("Scripting.FileSystemObject") If objFSO.Fileexists(saveFullDir) Then objFSO.DeleteFile saveFullDir Set objFSO = Nothing objADOStream.SaveToFile saveFullDir objADOStream.Close Set objADOStream = Nothing '// image/jpeg 등 반환 SaveFileFromUrl = objXMLHTTP.getResponseHeader("Content-Type") else SaveFileFromUrl = "" End if Set objXMLHTTP = Nothing End Function
'웹프로그래밍 > ASP Classic' 카테고리의 다른 글
Class Constructor 에 Arguments 전달 (0) | 2014.03.18 |
---|---|
HtmlZap - HTML parsing component (0) | 2013.11.13 |
Classic ASP 배열 커스텀 함수들 (0) | 2013.05.22 |
JSON Escape (0) | 2013.05.22 |
XML Escape/UnEscape (0) | 2013.05.22 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Docker
- Linux
- CSS
- iphone
- Debug
- nodejs
- javascript
- JSON
- iis
- 워드프레스
- API
- Android
- mssql
- Prototype
- IE
- ASP
- macos
- Wordpress
- Mac
- IOS
- classic asp
- sencha touch
- git
- PHP
- nginx
- 안드로이드
- JQuery
- centos
- 한글
- laravel
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함