如何让googlesearch的查询结果包含在自己的网页里? 用google ajax search apihttp://www.google.com/uds/samples/apidocs/helloworld.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 google 早期提供soap api 的,可以自己处理搜索结果,不过现在不做支持了。重点推出ajax apito dh20156(风之石):结果确实不多to ;yueliangdao0608((深圳PHPER)) 没研究过,调用而已 我看到别的网站直接引入一个google的js文件就搞定了。真是简单但是我下载下来改成自己的就不行了 我的实现方式服务器端:<%response.contenttype = "text/xml"%><%response.charset = "GB2312"%><!--#include file="../include/function.asp"--><%'on error resume nextFunction send_request(s) Set Retrieval = CreateObject("Microsoft.XMLHTTP") dim url url = "http://www.google.cn/search?q=" & s & _ "&ie=gb2312&hl=zh-CN&lr=lang_zh-cn&oe=utf-8&sa=N" With Retrieval .Open "Get", url, False, "", "" .setRequestHeader "Content-Length", len(url) .setRequestHeader "Content-Type", "application/x-www-form-urlencoded" .Send if err.number <> 0 then send_request = err.description else send_request = replace(.responsetext,"""",""") end if End With Set Retrieval = NothingEnd Functiondim keywordkeyword=Request("q")response.write "<?xml version=""1.0"" encoding=""GB2312""?>" & chr(13)response.write "<root>" & chr(13)response.write "<query><![CDATA[" & send_request(keyword) & "]]></query>" & chr(13)response.write "</root>"%>以上存为QueryWeb.asp客户端listBody2.innerHTML = "<img src=\"images/loading.gif\">数据正在查询,请稍候...";var keyword = keywords.innerText.split(" ");var q = "";for(i=0; i<keyword.length; i++){ q += i != keyword.length -1 ? keyword[i]+"+" : keyword[i];}url = "app/QueryWeb.asp?q="+q;XMLHttp.sendReq("GET", url, '', doWriteList22);function doWriteList22(http){ if(http.readyState == 4){ var xml = http.responseXML; var res = xml.selectSingleNode("root/query").childNodes[0].nodeValue; res = res.replace(/\"/ig, ''); var resArr = res.match(/<h2 class=r>((?!<\/h2>).)*<\/h2>/ig); var HTML = "<table width=100% cellpadding=5 cellspacing=0 border=0>"; var href = "", link = "", link2 = ""; for(i=0;i<10;i++){ if(i == resArr.length) break; href = resArr[i].match(/href=(.[^ ]*) /ig); link = resArr[i].match(/<a.*\/a>/ig); link2 = link[0].replace(/<(.[^>]*)>/ig,""); HTML += "<tr><td width=80% valign=center height=20px><img src=images/listHeader.gif> "+ "<a "+href[0].replace(/"/ig, "")+" target=_blank title=\""+link2+"\" class=tabList>"+link2.truncate(25)+"</a></td></tr>"; } HTML += "</table>" listBody2.innerHTML = HTML; }}用以上方式实现的页面,页面中点击左侧站外链接后就是通过GOOGLE搜索“关键字”后取得的内容http://www.speedsoftech.com/readnews.htm?newsid=49 如何知道图片的信息 上海日本上市公司寻PHP JAVA开发工程师。优厚待遇+4金+带薪假 急!header("location:register-02.php");跳转无效 祝福兼散分兼问问题 大侠!帮帮我啊! 求php读写xml的代码(类似留言簿核心代码) Apache2.0+PHPPHP-4.3.4-win32配置问题 怎么办呢 为各位带来特大喜讯,我开服务器支持PHP+MYSQL,免费提供,需要者联系 PHP能否使用COM控件????? 正则表达式啊,帮忙啊, 90%的php程序员都会答错的问题
结果确实不多to ;yueliangdao0608((深圳PHPER))
没研究过,调用而已
服务器端:
<%response.contenttype = "text/xml"%>
<%response.charset = "GB2312"%>
<!--#include file="../include/function.asp"-->
<%
'on error resume next
Function send_request(s)
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
dim url
url = "http://www.google.cn/search?q=" & s & _
"&ie=gb2312&hl=zh-CN&lr=lang_zh-cn&oe=utf-8&sa=N"
With Retrieval
.Open "Get", url, False, "", ""
.setRequestHeader "Content-Length", len(url)
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.Send
if err.number <> 0 then
send_request = err.description
else
send_request = replace(.responsetext,"""",""")
end if
End With
Set Retrieval = Nothing
End Functiondim keyword
keyword=Request("q")
response.write "<?xml version=""1.0"" encoding=""GB2312""?>" & chr(13)
response.write "<root>" & chr(13)
response.write "<query><![CDATA[" & send_request(keyword) & "]]></query>" & chr(13)
response.write "</root>"
%>
以上存为QueryWeb.asp客户端
listBody2.innerHTML = "<img src=\"images/loading.gif\">数据正在查询,请稍候...";
var keyword = keywords.innerText.split(" ");
var q = "";
for(i=0; i<keyword.length; i++){
q += i != keyword.length -1 ? keyword[i]+"+" : keyword[i];
}
url = "app/QueryWeb.asp?q="+q;
XMLHttp.sendReq("GET", url, '', doWriteList22);function doWriteList22(http){
if(http.readyState == 4){
var xml = http.responseXML;
var res = xml.selectSingleNode("root/query").childNodes[0].nodeValue;
res = res.replace(/\"/ig, '');
var resArr = res.match(/<h2 class=r>((?!<\/h2>).)*<\/h2>/ig);
var HTML = "<table width=100% cellpadding=5 cellspacing=0 border=0>";
var href = "", link = "", link2 = "";
for(i=0;i<10;i++){
if(i == resArr.length) break;
href = resArr[i].match(/href=(.[^ ]*) /ig);
link = resArr[i].match(/<a.*\/a>/ig);
link2 = link[0].replace(/<(.[^>]*)>/ig,"");
HTML += "<tr><td width=80% valign=center height=20px><img src=images/listHeader.gif> "+
"<a "+href[0].replace(/"/ig, "")+" target=_blank title=\""+link2+"\" class=tabList>"+link2.truncate(25)+"</a></td></tr>";
}
HTML += "</table>"
listBody2.innerHTML = HTML;
}
}用以上方式实现的页面,页面中点击左侧站外链接后就是通过GOOGLE搜索“关键字”后取得的内容
http://www.speedsoftech.com/readnews.htm?newsid=49