wikipedia: quick-and-dirty article printing.
parent
05f3092b9b
commit
a4f78c9515
|
@ -1,9 +1,12 @@
|
||||||
! Copyright (C) 2012 John Benediktsson
|
! Copyright (C) 2012 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
|
|
||||||
USING: accessors assocs calendar colors.constants formatting
|
USING: accessors ascii assocs calendar colors.constants
|
||||||
http.client io io.styles kernel make sequences urls xml
|
formatting html.parser html.parser.analyzer html.parser.printer
|
||||||
xml.data xml.traversal ;
|
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
|
IN: wikipedia
|
||||||
|
|
||||||
|
@ -61,3 +64,14 @@ PRIVATE>
|
||||||
|
|
||||||
: historical-deaths. ( timestamp -- )
|
: historical-deaths. ( timestamp -- )
|
||||||
(historical-events) "Deaths" header. fourth items. ;
|
(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 ;
|
||||||
|
|
Loading…
Reference in New Issue