ASP关于提取其中的链接地址
来源:百度知道 编辑:UC知道 时间:2024/09/12 15:36:43
<%
Function mymy_ad(siteid)
Dim myad_mode
myad_mode="test"
Dim myad_ua
myad_ua= Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))
Dim myad_ip
myad_ip = Server.URLEncode(Request.ServerVariables("REMOTE_ADDR"))
Dim myad_m
myad_m = ""
if myad_mode = "test" then
myad_m = "&m=test"
end if
Dim myad_a, myad_g, myad_e
myad_a = 0 ' OPTIONAL - user_age: 0-100
myad_g = "" ' OPTIONAL - user_gender:M or F
myad_e = "" ' OPTIONAL - user_education
Dim myad_url
myad_url = "http://www.mymyad.cn/SiteAd.php?sid=" & siteid & "&u=" & myad_ua & "&i="& myad_ip & myad_m & "&a=" & myad_a & "&g=" & myad_g & &
Function mymy_ad(siteid)
Dim myad_mode
myad_mode="test"
Dim myad_ua
myad_ua= Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT"))
Dim myad_ip
myad_ip = Server.URLEncode(Request.ServerVariables("REMOTE_ADDR"))
Dim myad_m
myad_m = ""
if myad_mode = "test" then
myad_m = "&m=test"
end if
Dim myad_a, myad_g, myad_e
myad_a = 0 ' OPTIONAL - user_age: 0-100
myad_g = "" ' OPTIONAL - user_gender:M or F
myad_e = "" ' OPTIONAL - user_education
Dim myad_url
myad_url = "http://www.mymyad.cn/SiteAd.php?sid=" & siteid & "&u=" & myad_ua & "&i="& myad_ip & myad_m & "&a=" & myad_a & "&g=" & myad_g & &
用正则过滤. 我帮你写了个函数,试试看吧
Function regx(patrn, str)
Dim regEx, Match, Matches
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(str)
For Each Match in Matches
RetStr = RetStr & Match.Value & " | "
Next
regx = RetStr
End Function
调用方法:regx("<a.*?<\/a>",mymy_ad("aeXCqapkrdaYryKtxHxckOsf"))
输出所有链接及其文字,用"|"分割.
如果是只要链接地址;
temp=regx("href=\"".*?\""",mymy_ad("aeXCqapkrdaYryKtxHxckOsf"))
然后temp=replace(temp,"href=""","")
temp=replace(temp,""","")
这样就可以得到所有纯粹的链接地址
用正则式查找 http(.*?)