1.google api 搜尋的調用
應用的js檔案是
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
2.初始化變量
<script type="text/javascript"> var googleSearchIframeName = 'googleSearchUnitIframe'; var googleSearchFrameWidth = 700; var googleSearchFrameborder = 0; var googleSearchDomain = 'www.google.com';</script>
3.返回結果的div
<div id="googleSearchUnitIframe"></div>
4.全部html代碼如下:
View Code
<html><head></head><body> <form method="get" target="_top"><table border="0" bgcolor="#FFFFFF"><tr><td nowrap="nowrap" valign="top" align="left" height="32"></td><td nowrap="nowrap"><input type="text" name="as_q" size="64" maxlength="255" value="" id="sbi" /><input type="submit" name="sa" value="查詢" id="sbb"></input></td></tr><tr><td> </td><td nowrap="nowrap"><table><tr><td><input type="radio" name="sitesearch" value="" checked id="ss0" /><label for="ss0" title="Search the Web"><font size="-1" color="#000000">Web</font></label></td><td><input type="radio" name="sitesearch" value="sohu.com" id="ss1" /><label for="ss1" title="Search sohu.com"><font size="-1" color="#000000">搜狐</font></label></td><td><input type="radio" name="sitesearch" value="cnblogs.com" id="ss2" /><label for="ss1" title="Search cnblogs.com"><font size="-1" color="#000000">部落格園</font></label></td></tr></table><input type="hidden" name="client" value="pub-5243795963266234" /><input type="hidden" name="forid" value="1" /><input type="hidden" name="ie" value="UTF-8" /><input type="hidden" name="oe" value="UTF-8" /><input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:#663399;AH:center;BGC:#FFFFFF;LBGC:#336699;ALC:#0000FF;LC:#0000FF;T:#000000;GFNT:#0000FF;GIMP:#0000FF;FORID:11" /><input type="hidden" name="hl" value="zh-CN" /></td></tr></table></form> <h1 class="title">搜尋結果</h1> <!-- Google Search Result Snippet Begins --><div id="googleSearchUnitIframe"></div><script type="text/javascript"> var googleSearchIframeName = 'googleSearchUnitIframe'; var googleSearchFrameWidth = 700; var googleSearchFrameborder = 0; var googleSearchDomain = 'www.google.com';</script><script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script></body></html>
5.使用介面如下:
6.上面 就是google的調用需要用到的東西,下面是要查詢的內容的設置
<form method="get" target="_top">
<table border="0" bgcolor="#FFFFFF">
<tr><td nowrap="nowrap" valign="top