如何用js提取带参数网页的内容?

nowman 2009-05-26 07:56:17

我想在ie中输入网页http://www.okrun.com/1.ashx?id=sdfr&end=3432&size=254432
1.ashx会执行将参数id=sdfr&end=3432&size=254432给另外一个网站的2.ashx
相当于我在网址上直接输入http://www.okrungo.com/2.ashx?id=sdfr&end=3432&size=254432
2.ashx执行完这条命令后会将结果显示在2.ashx中。就是一些文本内容。
现在问题来了,我想实现输入http://www.okrun.com/1.ashx?id=sdfr&end=3432&size=254432后我就能够看到2.ashx中的数据。
id=sdfr&end=3432&size=254432中的参数值都是变化的。2.ashx的内容也是变化的,
我需要每次在网页刷新http://www.okrun.com/1.ashx?id=sdfr&end=3432&size=254432时都可以看到最新的2.ashx中的数据。
我该怎么做?
现在我能实现输入http://www.okrun.com/1.ashx?id=sdfr&end=3432&size=254432就能
弹出http://www.okrungo.com/2.ashx?id=sdfr&end=3432&size=254432的新页面,内容也对,
就是不能将http://www.okrungo.com/2.ashx?id=sdfr&end=3432&size=254432页面中的内容
显示到http://www.okrun.com/1.ashx?id=sdfr&end=3432&size=254432页面中。如何才能在一页面中显示2.ashx中的内容呢?
着急,在线等!拜托使劲想想!我是新手!
...全文
320 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Msxindl_Com 2009-06-01
  • 打赏
  • 举报
回复
将你代码中的
Dim Url,Html,Usg,id
'id=Request("id")
'id=document.location.search
Url="http://www.okrungo.com/2.ashx?"+id
Html = getHTTPPage(Url)
Response.write Html
%>
改成:
Dim Url,id
id=request("id")
id=request.querystring
Url="http://www.okrungo.com/2.ashx?"&id
getHTTPPage(Url)
%>

要确保来到本页前已经对ID赋值。比如:
nowman 2009-05-31
  • 打赏
  • 举报
回复
'id=Request("id")
'id=document.location.search
这两个都是获取网页参数的。我在运行时取消了一个的注释。
nowman 2009-05-31
  • 打赏
  • 举报
回复
<%
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXml2.XmlHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
else
If Http.status=200 Then
response.write replace(BytesToBstr(http.responseBody,"gb2312"),chr(10),"")
End If
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset)'转换代码,不然全是乱码
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Url,Html,Usg,id
'id=Request("id")
'id=document.location.search
Url="http://www.okrungo.com/2.ashx?"+id
Html = getHTTPPage(Url)
Response.write Html
%>
这样都获得不了http://www.okrungo.com/2.ashx?id=sdfr&end=3432&size=254432的内容?为什么啊?请教大家帮忙看看程序是否有错?
nowman 2009-05-30
  • 打赏
  • 举报
回复
不好意思,我试过很多次了,都会在运行index.htm带参数时,都会弹出是否打开还是保存的对话框。保存的是index.htm这个文件。不能显示2.ashx中的文本文件。可能是我解释的不够详细。下面我再重新叙述一下我的需求。
其实我需要一个网页小偷的程序。是js语言的。获取不同域名的网页中的内容。要获取的网页需要输入例如http://www.yyy.com/2.ashx?id=2342&name=sdwerds&msg=2354&date=52435这样一个带参数的网页。这个网页2.ashx根据所给参数将数据文件显示到2.ashx?id=2342&name=sdwerds&msg=2354&date=52435这个文件中。我要在我的网站中添加一个网页1.ashx文件。和2.ashx参数相同。这是只要输入我的网页http://www.xxx.com/1.ashx?id=2342&name=sdwerds&msg=2354&date=52435后,我的网页就会将获取回来的数据显示到我的网页1.ashx中。由于两个网页不在同一个域中,所以不能使用xmlhttp来获取。请问我的1.ashx网页源代码该怎么编写能够实现我的要求?
Msxindl_Com 2009-05-28
  • 打赏
  • 举报
回复
一个简单的例子:

1、index.htm 代码如下:

<html>
<head></head>
<body>
<p>你可以在本页地址后面带上参数运行,就会在本页内返回参数返回的值.比如:</p>
<p>在后面加上 ?20+68= 之后运行,就会在下面显示20+68=88.</p>
<div id="show"></div>
<iframe src="" name="aa" id="aa" width="0" height="0"></iframe>
<script language="javascript">
var xx=document.location.search;
if(xx.length>1)
document.getElementById("aa").src="search.htm"+xx;
</script>
</body>
</html>


2、search.htm 代码如下:

<html>
<head></head>
<body>
<script language="javascript">
var xx=document.location.search;
var yy=xx.substr(1);
var y=yy.split("+");
var zz=parseInt(y[0])+parseInt(y[1]);
window.parent.document.getElementById("show").innerHTML="返回的值是: "+yy+zz;
</script>
</body>
</html>
nowman 2009-05-26
  • 打赏
  • 举报
回复
我的1.ashx中内容是
<script language="javascript">
var xx=document.location.search; //定义将1.ashx后面的参数提取回来,
start Request(http://www.okrun.com/2.ashx+xx); //将从1.ashx后面的参数提取回来的参数传给2.ashx,运行带参数2.ashx,
</script>

81,092

社区成员

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

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