From 271438a28d30fe3fd86ac297b4d59ff0e39c1684 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 26 Aug 2009 14:28:06 -0500 Subject: [PATCH] add find-images word --- extra/html/parser/analyzer/analyzer.factor | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index d206ae5f45..10fcd9c449 100755 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -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 ; + : ( vector -- link ) [ first attributes>> ] [ [ name>> { text "img" } member? ] filter ] bi