gethttppage(url) 如何用UTF-8编码获取网页内容?
url="http://www.域名.com/"html=r.gethttppage(url)html=replace(html,"域名/css/color.css","...
url = "http://www.域名.com/" html = r.gethttppage(url) html = replace(html,"域名/css/color.css","css/color.css") 如何用UTF-8编码获取指定网页内容呢
展开
1个回答
展开全部
你所说的GETHTTPPAGE是自定义函数,如果要获得UTF8的编码,是获取到内容后,进行转码,通常的方式是: 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,"utf-8") call writetotextfile("../static_view/"&strFolder&"/"&year(rs("ntime"))&month(rs("ntime"))&day(rs("ntime"))&rs("id")&".html",getHTTPPage,"utf-8") set http=nothing if err.number<>0 then err.Clear end if end function function writetotextfile(fileurl,str,cset) set stm=server.CreateObject("adodb.stream") stm.type=2 stm.mode=3 stm.charset=cset stm.open stm.writetext str stm.savetofile server.MapPath(fileurl),2 stm.flush stm.close set stm=nothing end function 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
希望采纳
希望采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询