Lasso Soft Inc. > Home

[yahoo_news]

Linkyahoo_news
AuthorJason Huck
CategoryUtility
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted20 Jul 2006
Updated20 Jul 2006
More by this author...

Description

Given a valid feed name for Yahoo! News, returns the current feed data as an array of maps.

Sample Usage

var('mynews') = yahoo_news('topstories');

iterate($mynews, local('i'));
	'

' + #i->find('title') + '

\n'; '' + #i->find('pubDate')->format('%D') + '\n'; '

' + #i->find('description') + '

\n'; /iterate;

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'news',
	-namespace='yahoo_',
	-req='feed',
	-priority='replace',
	-description='Retrieves the specified news feed from Yahoo! News.'
);
	local('out' = array);

	protect;
		local('data') = xml_tree(include_url('http://rss.news.yahoo.com/rss/' + #feed));
		
		handle_error;
			return;
		/handle_error;
	/protect;
	
	local('nodes') = array(
		'title',
		'link',
		'guid',
		'pubDate',
		'description',
		'content',
		'text',
		'credit'
	);
	
	iterate(#data->channel->item, local('i'));		
		local('temp' = map);
		
		iterate(#nodes, local('n'));
			protect;
				local('raw') = decode_html(#i->getnode(#n)->contents);
				#raw->trim;
				#n == 'pubDate' ? #raw = date(#raw, -format='%a, %d %b %Y %H:%M:%S GMT');	// Thu, 20 Jul 2006 16:22:22 GMT
				#temp->insert(#n = #raw);
			/protect;
		/iterate;
		
		#out->insert(#temp);
	/iterate;
	
	return(#out);
/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft