add find-images word

Doug Coleman 2009-08-26 14:28:06 -05:00
parent 913c0fa597
commit 271438a28d
1 changed files with 10 additions and 1 deletions

View File

@ -3,7 +3,7 @@
USING: assocs html.parser kernel math sequences strings ascii
arrays generalizations shuffle namespaces make
splitting http accessors io combinators http.client urls
urls.encoding fry prettyprint sets ;
urls.encoding fry prettyprint sets combinators.short-circuit ;
IN: html.parser.analyzer
TUPLE: link attributes clickable ;
@ -103,6 +103,15 @@ TUPLE: link attributes clickable ;
[ [ name>> "a" = ] [ attributes>> "href" swap at ] bi and ]
find-between-all ;
: find-images ( vector -- vector' )
[
{
[ name>> "img" = ]
[ attributes>> "src" swap at ]
} 1&&
] find-all
values [ attributes>> "src" swap at ] map ;
: <link> ( vector -- link )
[ first attributes>> ]
[ [ name>> { text "img" } member? ] filter ] bi