asp讀取動態(tài)頁面生成靜態(tài)頁面
來源:易賢網 閱讀:879 次 日期:2014-08-26 10:24:57
溫馨提示:易賢網小編為您整理了“asp讀取動態(tài)頁面生成靜態(tài)頁面”,方便廣大網友查閱!

<%

'常用函數

'1、輸入url目標網頁地址,返回值getHTTPPage是目標網頁的html代碼

function getHTTPPage(url)

dim Http

set Http=server.createobject("MSXML2.XMLHTTP")

Http.open "GET",url,false

Http.send()

if Http.readystate<>4 then

exit function

end if

getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")

set http=nothing

if err.number<>0 then err.Clear

end function

'2、轉換亂瑪,直接用xmlhttp調用有中文字符的網頁得到的將是亂瑪,可以通過adodb.stream組件進行轉換

Function BytesToBstr(body,Cset)

dim objstream

set objstream = Server.CreateObject("adodb.stream")

objstream.Type = 1

objstream.Mode =3

objstream.Open

objstream.Write body

objstream.Position = 0

objstream.Type = 2

objstream.Charset = Cset

BytesToBstr = objstream.ReadText

objstream.Close

set objstream = nothing

End Function

'txtURL=server.MapPath("http://bwnwqq.cn/default.asp")

txtURL="http://bwnwqq.cn/default.asp"

sText = getHTTPPage(txtURL)

Set FileObject=Server.CreateObject("Scripting.FileSystemObject")

filename="default.html"

Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'true為不存在自行建立

openFile.writeline(sText)

Set OpenFile=nothing

response.Write "生成成功"

%>

更多信息請查看IT技術專欄

更多信息請查看網絡編程
下一篇:ASP的err和error

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網