asp小偷程序中如何判断偷的页面编码?

xroha 2008-04-11 02:48:15
asp小偷程序中如何判断偷的页面编码?

本身是GB2312,如何判断远程得到的页面文件编码?
...全文
199 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
myvicy 2008-04-11
  • 打赏
  • 举报
回复
不用注释,6楼的是固定为gb2312了。
xroha 2008-04-11
  • 打赏
  • 举报
回复
多谢楼上两位!
xroha 2008-04-11
  • 打赏
  • 举报
回复
思路意思我明白了,

但是代码不会写,六楼的代码好象不是很正确。

文盲老顾 2008-04-11
  • 打赏
  • 举报
回复
六楼的意思其实就是采集后,在采集的内容中匹配 charset,如果有就返回匹配结果,没有就使用默认的设置
xroha 2008-04-11
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 myvicy 的回复:]
VBScript code '自动判断编码开始
Set re = New RegExp
re.Pattern = "CharSet=(\S+)"">"
re.IgnoreCase = True
' response.write http_request.ResponseText
' response.end
Dim charresult
' charresult = re.Execute(http_request.ResponseText)
If (charresult <> Null) Then
Cset = charresult(0)
Else
Cset = "gb2…
[/Quote]

能详解下代码吗?

好象不对啊,
' charresult = re.Execute(http_request.ResponseText)
要注解掉吗?
myvicy 2008-04-11
  • 打赏
  • 举报
回复
 '自动判断编码开始
Set re = New RegExp
re.Pattern = "CharSet=(\S+)"">"
re.IgnoreCase = True
' response.write http_request.ResponseText
' response.end
Dim charresult
' charresult = re.Execute(http_request.ResponseText)
If (charresult <> Null) Then
Cset = charresult(0)
Else
Cset = "gb2312" '对获取不到的网站采用gb2312编码,可自行更改
End If
xroha 2008-04-11
  • 打赏
  • 举报
回复
asp 不能判断采集到的信息是什么编码吗?是UTF-8还是GB2312?
文盲老顾 2008-04-11
  • 打赏
  • 举报
回复
那你采集两次吧。。。根据他的 meta 采集第二次

response.write server.htmlencode(getHttpPage("http://bbs.chinaz.com","UTF-8"))
xroha 2008-04-11
  • 打赏
  • 举报
回复
条件是:
首先不能确定要采集的目标网页是什么编码,可能是GB2312,也可能是UTF-8

要做到采集的内容都能在GB2312编码下正常显示,不出现乱码。

楼上的你把目标网址换成一个UTF-8编码的地址后,采集到的显示为乱码。

比如:response.write server.htmlencode(getHttpPage("http://bbs.chinaz.com","GB2312"))

就不正常了。
文盲老顾 2008-04-11
  • 打赏
  • 举报
回复
<%
Function BIN2STR(xBinary,Charset)
Dim RS, LBinary,Binary
Binary = xBinary
Const adLongVarChar = 201
Set RS = CreateObject("ADODB.Stream")
RS.Type = 1
RS.Mode =3
LBinary = LenB(Binary)

if LBinary>0 then
RS.Open
RS.Write Binary
RS.Position = 0
RS.Type = 2
RS.Charset = Charset
BIN2STR = RS.ReadText
Else
BIN2STR = ""
End If
End Function

Function getHttpPage(xUrl,Charset)
On Error Resume Next
Dim Http
Set Http = Server.CreateObject("Microsoft.XMLHTTP")
Http.Open "GET",xUrl,False
Http.Send()
If Http.ReadyState <> 4 Then
Response.Write "Error,Can't conect source."
getHttpPage = False
Exit Function
End If
getHttpPage = BIN2STR(Http.responseBody,Charset)
Set Http = Nothing
If Err Then
Response.Write "<p align='center'><font color='red'><b>Error ! " & Err.Description & "</b></font></p>"
getHttpPage = Err.description
Err.Clear
End If
End function

response.write server.htmlencode(getHttpPage("http://www.163.com","GB2312"))
%>
文盲老顾 2008-04-11
  • 打赏
  • 举报
回复
采集到的信息一般都是二进制的内容,自己转编码吧?

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧