[yahoo_news]

Description

Link: [yahoo_news]
Author: Jason Huck
Category: Utility
Version: 8.x
License:
Posted: Jul. 20, 2006
Updated: Jan. 01, 0001
More by this author...
Given a valid feed name for Yahoo! News, returns the current feed data as an array of maps.

Parameters

none


Sample Usage

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

iterate($mynews, local('i'));
	'<h4><a href="' + #i->find('link') + '" target="_blank">' + #i->find('title') + '</a></h4>\n';
	'<small>' + #i->find('pubDate')->format('%D') + '</small>\n';
	'<p>' + #i->find('description') + '</p>\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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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

none

Email:


Password:



Newest

Most Popular