脚本宝典收集整理的这篇文章主要介绍了XMLHTTP利用POST发送表单时提交中文的问题,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
刚才写一个小偷程序,突然发现一旦POST中文时抓取不到内容,考虑到
中文编码问题,像javascript中的esca
PE()一样,在
vbscript中也可以使用这个函数,只需要这个发送就可以
正常抓取到内容了send("A="&
amp;escape(A)&""&escape(B))
完成收工!
附几个小偷常用的function函数Function ByteToStr(vIn)
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & C
hr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &
h100 + CInt(NextCharCode))
i = i + 1
End If
Next
ByteToStr = strReturn
End Function
Function GetURL(url,PostStr)
Set Retrieval = Server.CreateObject("Microsoft.
XMLHTTP")
W
ITh Retrieval
.Open "POST", url, false ,"" ,""
.setRequestHeader "Content
-type","
application/x-www-form-url
encoded"
.Send(PostStr)
GetURL = .ResponseBody
End With
Set Retrieval = Nothing
GetURL=ByteToStr(GetURL)
End Function
Function RegE
xpText(strng,regStr)
Dim regEx,Match,Matches,RetStr
Set regEx = New RegExp
regEx.Pattern = regStr
regEx.IgnoreCase = True
regEx.Global = True
Set 
;matches = regEx.Execute(strng)
For
each Match in Matches
RetStr = RetStr & Match.Value & ","
Next
RegExpText = RetStr
set regEx=nothing
End Function
用法:Dim PostStr,getContent,getArea
PostStr = "action=
mobile&mobile="&MobileNumber
getContent = GetURL("
http://www.ip138.com:8080/search.asp",PostStr)
getArea = Replace(Replace(Replace(RegExpText(getContent,"卡号归属地</TD>((.|\n)*?)</TD>"),"卡号归属地</TD>",""),"<TD width=* align=""
center"" class=tdc2>",""),"</TD>,","")
Response.Write(getArea)
脚本宝典总结
以上是脚本宝典为你收集整理的XMLHTTP利用POST发送表单时提交中文的问题全部内容,希望文章能够帮你解决XMLHTTP利用POST发送表单时提交中文的问题所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。