Created
April 6, 2020 02:33
-
-
Save kobapan/b6b668f76219bc927263521b4e23538e to your computer and use it in GitHub Desktop.
get html body with uri (Gauche Scheme lisp)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use rfc.http) ; http-get http-compose-query | |
(use rfc.uri) ; uri-parse uri-compose | |
(define (uri-get uri :key (query #f)) | |
(if query (set! uri (string-append uri (if (car query) (http-compose-query "" query) | |
#"&~(http-compose-query #f (cdr query))")))) | |
(receive (code status body) | |
(receive (scheme user-info hostname port path query frament) | |
(uri-parse uri) | |
(http-get hostname (uri-compose :path path :query query))) | |
body)) | |
;; uri-get | |
;; | |
;; get html body with uri | |
;; | |
;; (use rfc.http) | |
;; (use rfc.uri) | |
;; | |
;; (uri-get "http://hoge.com/t/i?x=hoge&y=fuga") | |
;; | |
;; (uri-get "http://hoge.com/t/i" | |
;; :query '((x "hoge") | |
;; (y "fuga"))) | |
;; | |
;; (uri-get "http://hoge.com/t/i?z=1" | |
;; :query '(#f | |
;; (x "hoge") | |
;; (y "fuga"))) | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment