]> gitweb.factorcode.org Git - factor.git/blob - extra/rosetta-code/web-scraping/web-scraping.factor
sequences: rename subsequence? words to subseq? again.
[factor.git] / extra / rosetta-code / web-scraping / web-scraping.factor
1 ! Copyright (c) 2012 Anonymous
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: http.client io kernel math sequences ;
4 IN: rosetta-code.web-scraping
5
6 ! http://rosettacode.org/wiki/Web_scraping
7
8 ! Create a program that downloads the time from this URL:
9 ! http://tycho.usno.navy.mil/cgi-bin/timer.pl and then prints the
10 ! current UTC time by extracting just the UTC time from the web
11 ! page's HTML.
12
13 ! If possible, only use libraries that come at no extra monetary
14 ! cost with the programming language and that are widely available
15 ! and popular such as CPAN for Perl or Boost for C++.
16
17 : web-scraping-main ( -- )
18     "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip
19     [ "UTC" subseq-index [ 9 - ] [ 1 - ] bi ] keep subseq print ;
20
21 MAIN: web-scraping-main