如何跨域名提取网页的链接

smxhj 2003-03-26 02:41:06
我写了一个提取网页中所有链接的脚本,当要跨域名提取网页时,出现拒绝访问错误,能否解决?
比如
parent.disp.document.links.length
当disp帧中的网页是同一域名的网页时,能正常返回帧中的链接数。但当disp帧为跨域名的网页时,则出现拒绝访问错误。
...全文
104 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunicom 2003-09-06
  • 打赏
  • 举报
回复
学习
jam_lin 2003-03-31
  • 打赏
  • 举报
回复
如果链接不含中文字符,可改为
Function GetUrl(Url)
set oSend=createobject("Microsoft.XMLHTTP")
SourceCode = oSend.open ("GET",url,false)
oSend.send()
SourceCode = oSend.responseText
GetUrl = SourceCode
End Function
速度会更快
jam_lin 2003-03-31
  • 打赏
  • 举报
回复
Function GetUrl(Url)
set oSend=createobject("Microsoft.XMLHTTP")
SourceCode = oSend.open ("GET",url,false)
oSend.send()
SourceCode = bytes2BSTR(oSend.responseBody)
GetUrl = SourceCode
End Function
<SCRIPT LANGUAGE="VBScript">
Function bytes2BSTR(vIn)
strReturn = ""
For j = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,j,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,j+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
j = j + 1
End If
Next
bytes2BSTR = strReturn
End Function

通过GetUrl(网址)获得该页面的源代码后,自己再写程序提取网页的链接
netdust 2003-03-26
  • 打赏
  • 举报
回复
use xml on the server side maybe you can do that
emu_ston 2003-03-26
  • 打赏
  • 举报
回复
如果都是你自己的服务器:
http://expert.csdn.net/Expert/topicview.asp?id=1419092

如果在本地运行,通过hta也可。

否则……自己去写浏览器吧
smxhj 2003-03-26
  • 打赏
  • 举报
回复
没人帮忙解决吗?
saucer 2003-03-26
  • 打赏
  • 举报
回复
the browser doesn't allow you to do that, of course, you can always write your own or customize the browser

that is why I suggest you get the 跨域网页 on the server side, parse the content and get the 链接s
smxhj 2003-03-26
  • 打赏
  • 举报
回复
hehe,我说了跨域名提取,自然是指提取别人的网页中的链接了。
saucer 2003-03-26
  • 打赏
  • 举报
回复
do it on the server side
smxhj 2003-03-26
  • 打赏
  • 举报
回复
up

87,984

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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