Monday, November 08, 2010 at 12:07 AM.


on getHtmlLinks (urlHtml, adrtable) {
		<<11/4/09; 5:29:21 PM by DW
			<<Gather all the <link rel>s out of the HTML text in a table.
	local (s = tcp.httpreadurl (urlHtml, ctFollowRedirects:5), ix, ixright, xmltext, xstruct);
	new (tabletype, adrtable);
	loop {
		ix = string.patternmatch ("<link rel=", string.lower (s));
		if ix == 0 {
			return (false)};
		s = string.delete (s, 1, ix-1);
		ixright = string.patternmatch (">", s);
		xmltext = string.mid (s, 1, ixright);
		try {
			local (xstruct);
			xml.compile (xmltext, @xstruct);
			local (adrlink = xml.getaddress (@xstruct, "link"));
			local (adratts = @adrlink^.["/atts"]);
			adrtable^.[adratts^.href] = adratts^};
			<<scratchpad.xstruct = xstruct
		s = string.delete (s, 1, ixright)}}
<<bundle //test code
	<<getHtmlLinks ("", @scratchpad.links2)

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.