(: , , , . , .)
(defn download-web-page
"Downloads the webpage at the given url and returns its contents."
([^String url] (download-web-page url nil nil))
([^String url ^String user ^String password]
(with-open [client (doto (WebClient.)
(-> (.set_Credentials
(NetworkCredential. user password ""))
(->> (when user))))]
(.DownloadString client url))))
. :
(defn download-web-page
"Downloads the webpage at the given url and returns its contents."
([^String url] (download-web-page url nil nil))
([^String url ^String user ^String password]
(with-open [client (let [c (WebClient.)]
(when user
(.set_Credentials
(NetworkCredential. user password "")))
c)]
(.DownloadString client url))))
->/->> :
(defmacro doto-guard [guard action]
`(-> ~action ~guard))
(doto (WebClient.)
(doto-guard (when user) (.setCredentials ...)))
, doto doto. , , . let .
( , ... , , , ~guard (when ~guard), (doto-guard user (.setCredentials ...)). ).
- - nil nil, .