我是想要实时获取 有人访问我的网页的时候 自动从京东获取产品价格 用什么方法都可以 只要能帮我实现就好 我的是 ASP 站 先谢谢 啦
在线等呢 谁能帮我下 用这个帮我修改下也可以<% Dim cid cid=Request("cid")%> document.write("<%=a%> <%=cid%>") <% on error resume next function weather(cid) DIM Product(5) content = getHTTPPage("http://book.360buy.com/%cid%.html") cc = split(content," <span id=""priceinfo"" class=""price"">")
for each a in cc a1 = split(a,"</font></td><td>")'a1(0)为城市
if (a1(0)=city) then 'response.write a1(0)&a1(1) a2 = split(a1(1),"</td><td>")'a2(0)天气,a2(1)最高温度,a2(2)最低温度 Product(0) = city Product(1) = a2(0) Product(2) = a2(1) Product(3) = a2(2) a3 = split(a2(3),"</td>") Product(4) = a3(0) exit for end if 'response.write a&vbcrlf next weather = Product end functionresponse.write city&vbcrlf&a2(0)&vbcrlf&a2(1)&vbcrlf&a2(2)&vbcrlf&wind 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 FunctionFunction getHTTPPage(Path) t = GetBody(Path) getHTTPPage=BytesToBstr(t,"GB2312") End functionFunction GetBody(url) on error resume next Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url, False, "", "" .Send GetBody = .ResponseBody End With Set Retrieval = Nothing End Function %>
这个不用js也行啊 请求目标链接 抓取响应的html流,然后通过正则去截取你需要的数据点就好了
轻松搞定
Dim cid
cid=Request("cid")%>
document.write("<%=a%> <%=cid%>")
<%
on error resume next
function weather(cid)
DIM Product(5)
content = getHTTPPage("http://book.360buy.com/%cid%.html")
cc = split(content," <span id=""priceinfo"" class=""price"">")
'<span id="priceinfo" class="price">¥20.30</span>
response.write (cc)
for each a in cc
a1 = split(a,"</font></td><td>")'a1(0)为城市
if (a1(0)=city) then
'response.write a1(0)&a1(1)
a2 = split(a1(1),"</td><td>")'a2(0)天气,a2(1)最高温度,a2(2)最低温度
Product(0) = city
Product(1) = a2(0)
Product(2) = a2(1)
Product(3) = a2(2)
a3 = split(a2(3),"</td>")
Product(4) = a3(0)
exit for
end if
'response.write a&vbcrlf
next
weather = Product
end functionresponse.write city&vbcrlf&a2(0)&vbcrlf&a2(1)&vbcrlf&a2(2)&vbcrlf&wind
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 FunctionFunction getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage=BytesToBstr(t,"GB2312")
End functionFunction GetBody(url)
on error resume next
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
%>