Link | jc_harvest_meta |
Author | Jolle Carlestam |
Category | Utility |
Version | 9.x |
License | Public Domain |
Posted | 17 Sep 2012 |
Updated | 17 Sep 2012 |
More by this author... |
Experimental method that will harvest meta tags and title from an input assuming the input is HTML.
The method will return a map with the found tags content.
Note! It is probably impossible to construct a method that will work on all possible flavors of writing HTML code. Thus there's is no guarantee that this method will find all meta tags or titles in the given input.
local(html = include_url('http://www.lassosoft.com/')) jc_harvest_meta(#html) -> map(Author-Corporate = LassoSoft Inc., Author-Personal = LassoSoft Inc., contact = LassoSoft Inc., description = LassoSoft are the creators of the programming language Lasso - security, speed, simplicity - try Lasso today!, Formatter = LEAP 5.0, Generator = LEAP 5.0, keywords = Lasso,LassoTalk,Web Database Development,.Lasso,Web Security,Web Speed,Web development stability,Web systems,Data driven web development, meta_1 = http-equiv="content-type" content="text/html;charset=UTF-8" /, meta_13 = http-equiv="Reply-to" content="LassoSoft Inc." /, meta_2 = http-equiv="Content-Language" content="en" /, meta_7 = http-equiv="Resource-type" content="document" /, modification-date = 2012-09-17 20:52:04, MSSmartTagsPreventParsing = TRUE, owner = LassoSoft Inc., robots = index,follow, title = LassoSoft - Security. Speed. Simplicity.)
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.
{ local(content = string(#input)) local(found_info = map) local(tmp_content = string) local(reg_cleanup = regexp(-find = `\s`, -replace = ' ')) local(reg_title = regexp(-find = `Lasso Programming: (.*) `)) local(reg_metas =regexp(-find = ``)) local(reg_metaname =regexp(-find = `name( *?)=( *?)"(.*?)"`)) local(reg_metacontent =regexp(-find = `content( *?)=( *?)"(.*?)"`)) #reg_cleanup -> input = #content #content = #reg_cleanup -> replaceall #reg_title -> input = #content #reg_metas -> input = #content #found_info -> insert('title' = #reg_title -> find ? #reg_title -> matchstring(1) | string) while( #reg_metas -> find) => { #tmp_content = #reg_metas -> matchstring(1) #reg_metaname -> input = #tmp_content if(#reg_metaname -> find) => { #reg_metacontent -> input = #tmp_content #found_info -> insert(#reg_metaname -> matchstring(3) = #reg_metacontent -> find ? #reg_metacontent -> matchstring(3) | string) else #found_info -> insert('meta_' + loop_count = #tmp_content) } } return #found_info } ?>
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft