InterviewSolution
| 1. |
How Do I Fetch Web Pages And Make Http Requests? |
|
Answer» For the simple case of GETing a document into a string you can simply pass a URL to clojure.contrib.duck-streams/SLURP*: (use 'clojure.contrib.duck-streams) (slurp* "http://www.example.org/") ;; ⇒ "<HTML>rn<HEAD>rn <TITLE>Example WEB Page</TITLE> For more advanced usage, including other request types like POST you MAY find the clojure-http-client LIBRARY useful. FINALLY you can of course use (.openConnection) on a Java URL object directly. For the simple case of GETing a document into a string you can simply pass a URL to clojure.contrib.duck-streams/slurp*: (use 'clojure.contrib.duck-streams) (slurp* "http://www.example.org/") ;; ⇒ "<HTML>rn<HEAD>rn <TITLE>Example Web Page</TITLE> For more advanced usage, including other request types like POST you may find the clojure-http-client library useful. Finally you can of course use (.openConnection) on a Java URL object directly. |
|