Lasso Soft Inc. > Home

[yahoo_customnews]

Linkyahoo_customnews
AuthorJim Van Heule
CategoryUtility
Version8.x
LicensePublic Domain
Posted16 Jun 2008
Updated16 Jun 2008
More by this author...

Description

Given a valid feed name for Yahoo! Custom News, returns the current feed data as an array of maps. Use keywords using spaces between words.

This tag does not handle standard Yahoo news feeds. Yahho_News should be used for those.

Credit: Based on Jason Huck's yahoo_news tag and modified to handle custom news.

Sample Usage

[//lasso
'
'; ''; ''; '
'; 'Customize your news search with keywords'; var('mynews') = Yahoo_CustomNews(Action_Param:'newsitem'); // $mynews; If:$mynews -> (Size) > 0; iterate($mynews, local('i')); '

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

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

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

\n'; /iterate; /If; ]

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.

[//lasso
define_tag(
	'customnews',
	-namespace='yahoo_',
	-req='feed',
	-priority='replace',
	-description='Retrieves the specified news feed from Yahoo! Custom News.'
);
	local('out' = array);
	protect;
		#feed -> (Replace: ' ', '+');
		local('data') = xml_tree(include_url('http://news.search.yahoo.com/news/rss?p=' + #feed + '&ei=UTF-8&fl=0&x=wrt'));
		
		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;
]

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