2

次のリンクで https://github.com/swannodette/enlive-tutorial/blob/master/src/tutorial/scrape1.clj

URLからページを解析する方法を示していますが、sock5プロキシを使用する必要があり、enlive内でプロキシを使用する方法がわかりませんが、httpclientでプロキシを使用する方法は知っていますが、結果を解析する方法httpclient から、次のコードがありますが、最後の行に空の結果が表示されます

    (:require [clojure.set :as set]
                [clj-http.client :as client]
                [clj-http.conn-mgr :as conn-mgr]
                [clj-time.core :as time]
                [jsoup.soup :as soup]
                [clj-time.coerce :as tc]
                [net.cgrand.enlive-html :as html]
                )     
     (def a (client/get "https://news.ycombinator.com/"
                             {:connection-manager (conn-mgr/make-socks-proxied-conn-manager "127.0.0.1" 9150)
                              :socket-timeout 10000 :conn-timeout 10000
                              :client-params {"http.useragent" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20"}}))
(def b (html/html-resource a))
(html/select b [:td.title :a])
4

1 に答える 1