wikipedia: quick-and-dirty article printing.

db4
John Benediktsson 2013-10-11 11:52:53 -07:00
parent 05f3092b9b
commit a4f78c9515
1 changed files with 17 additions and 3 deletions

View File

@ -1,9 +1,12 @@
! 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
@ -61,3 +64,14 @@ PRIVATE>
: 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/ &lt;/ "<" re-replace
R/ &gt;/ ">" re-replace
R/ &amp;/ "&" re-replace
72 wrap-string print nl
] each ;