     ] map ;
 
 : find-by-id ( vector id -- vector' elt/f )
-    '[ attributes>> "id" swap at _ = ] find ;
+    '[ "id" attribute _ = ] find ;
     
 : find-by-class ( vector id -- vector' elt/f )
-    '[ attributes>> "class" swap at _ = ] find ;
+    '[ "class" attribute _ = ] find ;
 
 : find-by-name ( vector string -- vector elt/f )
     >lower '[ name>> _ = ] find ;
 
 : find-by-id-between ( vector string -- vector' )
     dupd
-    '[ attributes>> "id" swap at _ = ] find find-between* ;
+    '[ "id" attribute _ = ] find find-between* ;
     
 : find-by-class-between ( vector string -- vector' )
     dupd
-    '[ attributes>> "class" swap at _ = ] find find-between* ;
+    '[ "class" attribute _ = ] find find-between* ;
     
 : find-by-class-id-between ( vector class id -- vector' )
-    '[
-        [ attributes>> "class" swap at _ = ]
-        [ attributes>> "id" swap at _ = ] bi and
-    ] dupd find find-between* ;
+    [
+        '[
+            [ "class" attribute _ = ]
+            [ "id" attribute _ = ] bi and
+        ] find
+    ] [
+        2drop find-between*
+    ] 3bi ;
 
 : find-by-attribute-key ( vector key -- vector' elt/? )
     >lower

! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
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 combinators.short-circuit ;
IN: html.parser.analyzer

TUPLE: link attributes clickable ;

: scrape-html ( url -- headers vector )
    http-get parse-html ;

: find-all ( seq quot -- alist )
   [ <enum> >alist ] [ '[ second @ ] ] bi* filter ; inline

: find-nth ( seq quot n -- i elt )
    [ <enum> >alist ] 2dip -rot
    '[ _ [ second @ ] find-from rot drop swap 1 + ]
    [ f 0 ] 2dip times drop first2 ; inline

: find-first-name ( vector string -- i/f tag/f )
    >lower '[ name>> _ = ] find ; inline

: find-between* ( vector i/f tag/f -- vector )
    over integer? [
        [ tail-slice ] [ name>> ] bi*
        dupd find-matching-close drop [ 1 + ] [ 1 ] if*
        head
    ] [
        3drop V{ } clone
    ] if ; inline
