判断网页里面是否存在【Referer判断跳转】

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Session.CodePage=65001%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>模拟百度跳转页面</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	overflow:hidden;
}
.STYLE3 {font-size: 12px; color: #adc9d9; }
-->
</style></head>

<body>
<table width="100%"  height="100%" border="0" cellspacing="0" cellpadding="0"  οnsubmit="return checkinput();">
  <tr>
    <td bgcolor="#1075b1" align="center">
	<form id="addfrm" name="addfrm" action="" method="post">
          <input type="text" name="txtUrl" id="txtUrl" style="width:300px; height:25px; background-color:#87adbf; border:solid 1px #153966; font-size:16px; color:#283439; " value="http://www123.wangzhuanb.top/">
		  <input type="hidden" name="subflag" value="1">
		  <input type="submit" value="模拟">
    </form>
    </td>
  </tr>
  <tr>
  <td>
  <div style="overflow-y:scroll;height:600px;">

  <% 
  Function SaveTOFile(ByVal FileName,ByRef Content,ByVal Chrset)
	On Error Resume Next
	dim stm:set stm=Server.CreateObject("ADODB.Stream")
	stm.Type=1
	stm.Mode=3
	stm.CharSet=Chrset
	stm.Open
	stm.Write content
	stm.SaveToFile Server.MapPath(FileName),2 
	stm.Flush
	stm.Close
	Set stm=Nothing
   If Err Then
	 WriteTOFile = False
   Else
	 WriteTOFile = True
   End If
End Function
Dim SubFlag
SubFlag = Request.form("subflag")
If Not IsNull(SubFlag) and Trim(SubFlag)<>"" Then
	Dim WinHttp 
	Set WinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1") 
	'设置参数 
	WinHttp.SetTimeouts 60000, 60000, 60000, 3000 '设置操作超时时间 
	'WinHttp.SetTimeouts resolveTimeout, connectTimeout, sendTimeout, receiveTimeout 
	'resolveTimeout = 10000 '解析 DNS 名字的超时时间,10000 毫秒。 
	'connectTimeout = 10000 '建立 Winsock 连接的超时时间,10000 毫秒。 
	'sendTimeout = 120000 '发送数据的超时时间,120000 毫秒。 
	'receiveTimeout = 60000 '接收 response 的超时时间,60000 毫秒。 
	WinHttp.Option(4) = 13056 '忽略错误标志 
	WinHttp.Option(6) = 0  '为 True 时,当请求页面重定向跳转时自动跳转,False 不自动跳转,截取服务端返回的302状态。 
	WinHttp.Open "GET", Trim(Request.form("txtUrl")), True 'GET 或 POST, Url, False 同步方式;True 异步方式 http://www123.wangzhuanb.top/
	'组成 HTTP 头信息 
	WinHttp.SetRequestHeader "Accept", "*/*" '接受数据类型 
	WinHttp.SetRequestHeader "Accept-Language", "zh-cn,zh" '用户系统语言 
	WinHttp.SetRequestHeader "User-Agent", "Mozilla/6.0" '用户浏览器信息 
	WinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded" '编码方式 
	WinHttp.SetRequestHeader "Referer", "http://www.baidu.com/" '来路 
	WinHttp.SetRequestHeader "Connection", "Close" 'Close = 不保持连接,Keep-Alive = 保持连接(持久连接) 
	'WinHttp.SetRequestHeader "Accept-Encoding", "gzip, deflate" '如果发送,会返回 gzip, deflate 压缩过的编码 
	'WinHttp.SetRequestHeader "Content-Length", Len(Str) '内容长度,Post 方式用的。 
	WinHttp.SetRequestHeader "Cookie", "test cookie!" '设置 Cookie 
	'发送数据 
	WinHttp.Send 'Post 方式:WinHttp.Send (参数) 
	WinHttp.WaitForResponse '等待返回请求,XMLHTTP中也可以使用 
	'输出结果 
	Response.Write WinHttp.Status '当前 HTTP 状态 
	'Response.Write WinHttp.ResponseText '文本数据 
	'Response.BinaryWrite WinHttp.ResponseBody '二进制数据流数据 
    SaveTOFile "1.html",WinHttp.ResponseBody,"utf-8"
%>
 <iframe src="1.html" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width=100% height=100% id="iframepage" name="iframepage"></iframe>
<%
Else
%>

<%
End If
%>
</div> 
</td>
  </tr>
  <tr>
    <td bgcolor="#152753"> </td>
  </tr>
</table>
</body>
<SCRIPT LANGUAGE="JavaScript">
	function checkinput()
	{
		if (document.forms["addfrm"]["txtUrl"].value==""){
		alert("提示:路径名称不能为空!");
		return false;
		}
		return true;
	}

	</SCRIPT>
</html>

上面是asp代码,模拟页面从百度跳转过去。

效果如下:

输入网址后,点击模拟。

就模拟了百度跳转到此页面。http://www123.wangzhuanb.top网址源码如下:

但是如果测试的网页document.referrer判断跳转写到外部js中,这种方法就没法处理了。

例如:这种。http://yao.shiyan676.pw 网页源码如下:

它的跳转是在tz.js里面,如下图:

这样用asp的方法就不可以了。C#HttpHelper官方产品发布与源码下载---苏飞版也是不可以。

整了一下午,没有找到好的方法,最后用网页爬虫处理了。

抓取网址代码,判断是否包含【document.referrer】判断跳转,如果有判断,获取js里面的http://路径。

部分代码如下:


猜你喜欢

转载自blog.csdn.net/adsdassadfasdfasdf/article/details/51008094