]> gitweb.factorcode.org Git - factor.git/commitdiff
http.client: use new http-get* word.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 12 Oct 2013 17:25:42 +0000 (10:25 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 12 Oct 2013 17:25:42 +0000 (10:25 -0700)
18 files changed:
basis/bootstrap/image/download/download.factor
basis/concurrency/semaphores/semaphores-docs.factor
basis/syndication/syndication.factor
extra/bit/ly/ly.factor
extra/google/search/search.factor
extra/google/translate/translate.factor
extra/hacker-news/hacker-news.factor
extra/html/parser/analyzer/analyzer.factor
extra/mason/updates/updates.factor
extra/reddit/reddit.factor
extra/robots/robots.factor
extra/rosetta-code/web-scraping/web-scraping.factor
extra/twitter/prettyprint/prettyprint.factor
extra/webapps/fjsc/fjsc.factor
extra/wikipedia/wikipedia.factor
extra/wolfram-alpha/wolfram-alpha.factor
extra/xkcd/xkcd.factor
extra/yahoo/yahoo.factor

index 15a0e679c54299f2b02acf47e3a11a456aecf4cd..9d613a5148849b109ba72a2abb3c9bed9d0ed72a 100644 (file)
@@ -7,7 +7,7 @@ IN: bootstrap.image.download
 CONSTANT: url URL" http://downloads.factorcode.org/images/latest/"
 
 : download-checksums ( -- alist )
-    url "checksums.txt" >url derive-url http-get nip
+    url "checksums.txt" >url derive-url http-get*
     string-lines [ " " split1 ] { } map>assoc ;
 
 : file-checksum ( image -- checksum )
index a922431d48d6191133eb18f7cfb742ca80df7678..4fdecee2736bf13371d0a89d3ab504c44642bbe8 100644 (file)
@@ -53,9 +53,7 @@ fry http.client kernel urls ;
     URL" http://www.oracle.com"\r
 }\r
 2 <semaphore> '[\r
-    _ [\r
-        http-get nip\r
-    ] with-semaphore\r
+    _ [ http-get* ] with-semaphore\r
 ] parallel-map"""\r
 } ;\r
 \r
index 407e09aab11dbd68c50ae0b6a10c087ae414b55e..8e9150f69353f67bd6110ea01dc2185b4b26d8d4 100644 (file)
@@ -108,7 +108,7 @@ M: byte-array parse-feed [ bytes>xml xml>feed ] with-html-entities ;
 
 : download-feed ( url -- feed )
     #! Retrieve an news syndication file, return as a feed tuple.
-    http-get nip parse-feed ;
+    http-get* parse-feed ;
 
 ! Atom generation
 
index f69eff34b011e2f140b54c89c3461a5468ab1d34..c89c3791bd704791984755bdc87eda951a1968b5 100644 (file)
@@ -23,7 +23,7 @@ ERROR: bad-response json status ;
     ] unless ;
 
 : json-data ( url -- json )
-    http-get nip json> check-status "data" of ;
+    http-get* json> check-status "data" of ;
 
 : get-short-url ( short-url path -- data )
     <bitly-url> swap "shortUrl" set-query-param json-data ;
index 4518b114808dcfed03cf016b3b8a0adcc2c37809..d3d8002f7ab79d074a1154b9bf5b8e8b20212134 100644 (file)
@@ -22,7 +22,7 @@ title content unescapedUrl url titleNoFormatting fileFormat ;
 PRIVATE>
 
 : google-search ( query -- results )
-    search-url http-get nip json>
+    search-url http-get* json>
     { "responseData" "results" } deep-at
     [ \ search-result from-slots ] map ;
 
index e515e749bd2d8113d2825bef72724387abdd38b7..c08ed8979a59a79b4ea3a87819e8dc2802d7ad6c 100644 (file)
@@ -53,7 +53,7 @@ ERROR: response-error response error ;
 
 : translate-tts ( text -- file )
     "http://translate.google.com/translate_tts?tl=en" >url
-    swap "q" set-query-param http-get nip
+    swap "q" set-query-param http-get*
     temporary-file ".mp3" append
     [ binary set-file-contents ] keep ;
 
index e7faaccf38a2779778b1ed1d0c4f046e49b85a08..3e2e91f186fb486fd8e847eccce9634adfb6ed00 100644 (file)
@@ -25,7 +25,7 @@ TUPLE: post title postedBy points id url commentCount postedAgo ;
     ] map ;
 
 : hacker-news-items ( -- seq )
-    "http://api.ihackernews.com/page" http-get nip
+    "http://api.ihackernews.com/page" http-get*
     json> "items" of items> ;
 
 : write-title ( title url -- )
index 952b34421692eeae9c46ef2bc7efa590f6569284..35716860d199b657ce5e3a96d9863cb1ab7e4f16 100644 (file)
@@ -6,7 +6,7 @@ sequences sets splitting unicode.case unicode.categories urls
 urls.encoding shuffle ;
 IN: html.parser.analyzer
 
-: scrape-html ( url -- headers vector )
+: scrape-html ( url -- response vector )
     http-get parse-html ;
 
 : attribute ( tag string -- obj/f )
index 016c1a6d7974da4fa87aa844d0f308e2c5be7271..ca24d98515260e261ee71261d4ea6a5fcf0ddc72 100644 (file)
@@ -21,7 +21,7 @@ SYMBOLS: latest-sources last-built-sources ;
     [ maybe-download-image drop ] [ file-checksum ] bi ;
 
 : latest-counter ( -- counter )
-    counter-url get-global http-get nip string>number ;
+    counter-url get-global http-get* string>number ;
 
 : update-sources ( -- )
     #! Must be run from builds-dir
index 5a8c96ad6c9b150e0532ba0265c542796da3e114..7556a7ba5878db145dfdfdf6c67780019f0752ef 100644 (file)
@@ -43,7 +43,7 @@ public_description subscribers title url ;
 TUPLE: page url data before after ;
 
 : json-page ( url -- page )
-    >url dup http-get nip json> "data" of {
+    >url dup http-get* json> "data" of {
         [ "children" of [ parse-data ] map ]
         [ "before" of [ f ] when-json-null ]
         [ "after" of [ f ] when-json-null ]
@@ -54,7 +54,7 @@ TUPLE: page url data before after ;
 
 : get-user-info ( username -- user )
     "http://api.reddit.com/user/%s/about" sprintf
-    http-get nip json> parse-data ;
+    http-get* json> parse-data ;
 
 : get-url-info ( url -- page )
     "http://api.reddit.com/api/info?url=%s" sprintf json-page ;
index e99a51e6409704d346485078e11d8738c9989835..580e965348148756c8f210df8b54f2e3815850f7 100644 (file)
@@ -29,8 +29,8 @@ visit-time request-rate crawl-delay unknowns ;
 : >robots.txt-url ( url -- url' )
     >url URL" robots.txt" derive-url ;
 
-: get-robots.txt ( url -- headers robots.txt )
-    >robots.txt-url http-get ;
+: get-robots.txt ( url -- robots.txt )
+    >robots.txt-url http-get* ;
 
 : normalize-robots.txt ( string -- sitemaps seq )
     string-lines
@@ -98,5 +98,4 @@ PRIVATE>
     ] map ;
 
 : url>robots ( url -- robots )
-    >url
-    dup get-robots.txt nip parse-robots.txt <robots> ;
+    >url dup get-robots.txt parse-robots.txt <robots> ;
index 402a960124e28422ceadd9f03249ac68bb4ac10d..66f6f7c91b81986df2e893f529848d2dd1aa4da0 100644 (file)
@@ -15,7 +15,7 @@ IN: rosetta-code.web-scraping
 ! and popular such as CPAN for Perl or Boost for C++.
 
 : web-scraping-main ( -- )
-    "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip
+    "http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get*
     [ "UTC" swap start [ 9 - ] [ 1 - ] bi ] keep subseq print ;
 
 MAIN: web-scraping-main
index e89c5bef3b2a89392aafa34b2d26b064b0a6cc6d..00b3fcc15992450cff7173e289e2f4d3a4797ae3 100644 (file)
@@ -5,8 +5,7 @@ IN: twitter.prettyprint
 
 MEMO: load-http-image ( url -- image/f )
     '[ _
-        [ http-get [ check-response drop ] dip ]
-        [ image-class ] bi load-image*
+        [ http-get* ] [ image-class ] bi load-image*
     ] [ drop f ] recover ;
 
 : user-image ( user -- image/f )
index 01d6935bee7d1658069e3a82c9c185b3563c0ee3..6901ea05643c5ea0b3a423e76113d1e95e3892de 100644 (file)
@@ -35,7 +35,7 @@ TUPLE: fjsc < dispatcher ;
 
 : do-compile-url ( url -- response )
     [ 
-        absolute-url http-get nip 'expression' parse fjsc-compile write "();" write
+        absolute-url http-get* 'expression' parse fjsc-compile write "();" write
     ] with-string-writer
     "application/javascript" <content> ;
 
index 5c2e24ebb29f539d1733dba7e24d3443da1b6d80..dc476ed9c2852456e7d3425013b38ae029218126 100644 (file)
@@ -40,7 +40,7 @@ IN: wikipedia
     "http://en.wikipedia.org/wiki/%s_%s" sprintf ;
 
 : (historical-events) ( timestamp -- seq )
-    historical-url http-get nip string>xml "ul" deep-tags-named ;
+    historical-url http-get* string>xml "ul" deep-tags-named ;
 
 : items>sequence ( tag -- seq )
     children-tags [ deep-children>string ] map ;
@@ -67,7 +67,7 @@ PRIVATE>
 
 : article. ( name -- )
     "http://en.wikipedia.org/wiki/%s" sprintf
-    http-get nip parse-html "content" find-by-id-between
+    http-get* parse-html "content" find-by-id-between
     [ html-text. ] with-string-writer string-lines
     [ [ blank? ] trim ] map harvest [
         R/ &lt;/ "<" re-replace
index 91a4c3b36b7ea3ea4227869b0b64e4a93d564e49..3766cecfa4a8203bdd62ede45a0b7d2b6729a71d 100644 (file)
@@ -16,7 +16,7 @@ SYMBOL: wolfram-api-id
 : query ( query -- xml )
     url-encode wolfram-api-id get-global
     "http://api.wolframalpha.com/v2/query?input=%s&appid=%s"
-    sprintf http-get nip string>xml
+    sprintf http-get* string>xml
     dup "error" tag-named [
         "msg" tag-named children>string throw
     ] when* ;
index 872493d6750365acf79f50839fbc25d3ff1944e6..f47be6483ef8ac02ca03875133d0b1d8cdaf8b77 100644 (file)
@@ -11,14 +11,14 @@ IN: xkcd
 <PRIVATE
 
 : comic-image ( url -- image )
-    http-get nip
+    http-get*
     R" http://imgs\.xkcd\.com/comics/[^\.]+\.(png|jpg)"
     first-match >string load-http-image ;
 
 : comic-image. ( url -- ) comic-image image. ;
 
 : comic-string ( url -- string )
-    http-get nip string>xml
+    http-get* string>xml
     "transcript" "id" deep-tag-with-attr children>string ;
 
 : comic-text. ( url -- )
index 7800095330c6fc4a0ea4613862827c6c0b3f73e2..9a7ab253907f06b38ffdbc284d64f2774b807b10 100644 (file)
@@ -57,4 +57,4 @@ CONSTANT: factor-id "fRrVAKzV34GDyeRw6bUHDhEWHRedwfOC7e61wwXZLgGF80E67spxdQXuugB
         swap >>query ;
 
 : yahoo-search ( search -- seq )
-    query http-get nip string>xml parse-yahoo ;
+    query http-get* string>xml parse-yahoo ;