Clojure building of URL from constituent parts

后端 未结 5 1211
余生分开走
余生分开走 2021-02-07 17:46

In Python I would do the following:

>>> q = urllib.urlencode({\"q\": \"clojure url\"})
>>> q
\'q=clojure+url\'

>>> url = \"http://sta         


        
5条回答
  •  庸人自扰
    2021-02-07 18:43

    clj-apache-http is pretty useful. With it you can do the following:

    user=> (require ['com.twinql.clojure.http :as 'http])
    nil
    user=> (def q (http/encode-query {"q" "clojure url"}))
    #'user/q
    user=> (def url (str "http://stackoverflow.com/search?" q))
    #'user/url
    user=> url
    "http://stackoverflow.com/search?q=clojure+url"
    

提交回复
热议问题