! Copyright (C) 2012 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: accessors assocs calendar colors.constants formatting
-http.client io io.styles kernel make sequences urls xml
-xml.data xml.traversal ;
+USING: accessors ascii assocs calendar colors.constants
+formatting html.parser html.parser.analyzer html.parser.printer
+http.client io io.streams.string io.styles kernel make regexp
+sequences splitting urls wrap.strings xml xml.data
+xml.traversal ;
+FROM: xml.data => tag? ;
IN: wikipedia
: historical-deaths. ( timestamp -- )
(historical-events) "Deaths" header. fourth items. ;
+
+: article. ( name -- )
+ "http://en.wikipedia.org/wiki/%s" sprintf
+ http-get nip parse-html "content" find-by-id-between
+ [ html-text. ] with-string-writer string-lines
+ [ [ blank? ] trim ] map harvest [
+ R/ </ "<" re-replace
+ R/ >/ ">" re-replace
+ R/ &/ "&" re-replace
+ 72 wrap-string print nl
+ ] each ;