Instantly share code, notes, and snippets.

What would you like to do?
(ns twitter-search
(:require [ :as json])
(:require [clojure.contrib.http.agent :as http ])
(:import ( URL URLEncoder))
(defn search [word last-id]
(let [term (URLEncoder/encode word "UTF-8")
result (http/string (http/http-agent (str
word "&since-id=" @last-id "&rpp=50")))]
(send last-id (fn [a] (get (json/read-json result) "max_id")))
(reduce (fn [t0 t1] (str t0 "\n" t1))
(reverse (map
(fn [tweet]
(str "@" (get tweet "from_user") " : " (get tweet "text")))
(get (json/read-json result) "results")
(defn -main [word]
(while true
(let [last-id (agent 0)]
(do (println (search word last-id))
(java.lang.Thread/sleep 15000)
(-main "diogok")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment