]> gitweb.factorcode.org Git - factor.git/commitdiff
html.parser.analyzer: find-classes-named word.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 4 Jun 2018 02:33:23 +0000 (21:33 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 4 Jun 2018 02:33:55 +0000 (21:33 -0500)
extra/html/parser/analyzer/analyzer.factor

index cf275bcba1ac97b3a37c8f77e52efb987d3f8d9c..1e004c09eceb67ff968efc57b81e77e35e896c44 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators combinators.short-circuit
-fry html.parser http.client io kernel locals math math.statistics
-sequences sets splitting unicode urls urls.encoding shuffle ;
+USING: accessors assocs assocs.extras combinators
+combinators.short-circuit fry html.parser http.client io kernel
+locals math math.statistics sequences sets shuffle splitting
+unicode urls urls.encoding ;
 IN: html.parser.analyzer
 
 : scrape-html ( url -- response vector )
@@ -204,3 +205,13 @@ TUPLE: link attributes clickable ;
 : link. ( vector -- )
     [ "href" attribute write nl ]
     [ clickable>> [ bl bl text>> print ] each nl ] bi ;
+
+: find-classes-named ( seq name -- seq' )
+    dupd
+    '[ attributes>> "class" of _ = ] find-all
+    [ find-between ] kv-with { } assoc>map ;
+
+: find-classes-named* ( seq name -- seq' )
+    dupd
+    '[ attributes>> "class" of _ = ] find-all
+    [ find-between* ] kv-with { } assoc>map ;