kittu
Joined: 05 Sep 2008 Posts: 26
|
Posted: Wed Apr 01, 2009 6:46 am Post subject: Working with Google News API |
|
|
<html>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
google.load("prototype", "1.6.0.3");
google.load("search", "1");
var searcher;
function processSearchResults()
{
var results = searcher.results;
for (var i=0; i<results.length; i++)
{
var divnode =new Element('div');
var subdiv =new Element('div');
divnode.appendChild(subdiv);
var dt = new Date(unescape(results[i].publishedDate));
subdiv.appendChild(new Element('div', { 'style':'float:left;padding-right:5px;'}).update(dt.getMonth() + "/" + dt.getDate() + "/" + dt.getYear()));
subdiv.appendChild(new Element('a', { href: unescape(results[i].url) }).update( unescape(results[i].titleNoFormatting)));
subdiv.appendChild(new Element('br'));
//divnode.appendChild(new Element('p', { 'class': 'news_result_detail'}).update(unescape(results[i].content)));
$('results_div').appendChild(divnode);
}
}
function doSearch()
{
searcher = new google.search.NewsSearch();
searcher.setSearchCompleteCallback(null,processSearchResults);
searcher.execute("\"sun microsystems\" [layoff OR \"plant closure\" OR merger OR divestiture OR \"profit warning\" OR restructuring OR \"corporate relocation\" OR upgrade OR downgrade]");
searcher.execute("\"boulder, co\" [zoning OR \"real *\" OR \"home prices\" OR foreclosures OR \"city council\" OR \"home sales\"]");
}
</script>
<body onLoad="doSearch()">
<h1>News Search</h1>
<div id="results_div"></div>
</body>
</html> |
|