用google ajax search apihttp://www.google.com/uds/samples/apidocs/helloworld.html

解决方案 »

  1.   

    google 早期提供soap api 的,可以自己处理搜索结果,不过现在不做支持了。重点推出ajax apito dh20156(风之石):
    结果确实不多to ;yueliangdao0608((深圳PHPER)) 
    没研究过,调用而已
      

  2.   

    我看到别的网站直接引入一个google的js文件就搞定了。真是简单但是我下载下来改成自己的就不行了
      

  3.   

    我的实现方式
    服务器端:
    <%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,"""","&quot;")
        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(/&quot;/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