]> gitweb.factorcode.org Git - factor.git/commitdiff
add find-images word
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 26 Aug 2009 19:28:06 +0000 (14:28 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 26 Aug 2009 19:28:06 +0000 (14:28 -0500)
extra/html/parser/analyzer/analyzer.factor

index d206ae5f45110a4901429b911f5ef8cc7aada0f8..10fcd9c449ade7c150ae2cb4469fa209cc13b645 100755 (executable)
@@ -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