现在的位置: 首页 > 综合 > 正文

用asp读取网页源代码

2013年12月10日 ⁄ 综合 ⁄ 共 958字 ⁄ 字号 评论关闭

<%
Function bytes2BSTR(vIn)
 strReturn = ""
 For i = 1 To LenB(vIn)
  ThisCharCode = AscB(MidB(vIn,i,1))
  If ThisCharCode < &H80 Then
   strReturn = strReturn & Chr(ThisCharCode)
  Else
   NextCharCode = AscB(MidB(vIn,i+1,1))
   strReturn = strReturn & Chr (CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
   i = i + 1
  End If
 Next
 bytes2BSTR = strReturn
End Function

QUrl = Request.QueryString("url")
if QUrl<>"" then
 set oSend=createobject("Microsoft.XMLHTTP")
 SourceCode = oSend.open ("GET",QUrl,false)
 oSend.send()
 if err.number<>0 then
  Response.write err.description
  Response.End()
 end if 
 SourceCode = bytes2BSTR(oSend.responseBody)
 if Request.QueryString("type")<>"" then
  response.write Server.HTMLEncode(SourceCode)
 else
  response.write SourceCode
 end if
end if
%>
fdasdfasdfdsafasdfasdfasfasd
<form action="" method="get">
  <p>
  <input name="url" type=text id="url">
  </p>
  <p>
    <label>
    <input type="radio" name="type" value="radiobutton" />
    显示代码</label>
  </p>
  <p>
    <input type="submit" name="Submit" value="提交" />
      </p>
</form>

抱歉!评论已关闭.