Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: slashsearch Arguments: term Description: Show recent slashdot posts containing specified term Page type: webl Render function: Module: global Page source: var P = GetURL("http://slashdot.org/search.pl", [. tid="", query=term, author="", sort="1", op="stories" .] ); // Select all "div" elements of class "search-results" var pieces = Select(Elem(P, "div"), fun(e) (e.class == "search-results") ? false end); // Accumulate them in piece result var result = NewPiece("","text/html"); every p in pieces do var title = Elem(p,"h4")[0]; var divs = Elem(p,"div"); // divs[0] is date etc., divs[1] is intro // Clean up unneeded text Delete(Pat(divs[0], `On `)); Delete(Pat(divs[0], `with \w* comments`)); Delete(Pat(divs[1], `.* writes "`)); // Create new paragraph with title, data, and intro var entry = NewNamedPiece("p",Content(title)); InsertBefore(EndTag(entry), Content(divs[1])); InsertBefore(EndTag(entry), Content(divs[0])); // Add paragraph to results InsertBefore(EndTag(result), entry) end; if Size(pieces) == 0 then result = NewPiece("<b>No results</b>","text/html"); end; result