Fix the html cover scraping (lovelybooks changed the html again)
This commit is contained in:
parent
641fcb8712
commit
695afe17db
1 changed files with 12 additions and 9 deletions
|
@ -27,13 +27,16 @@
|
||||||
[me.raynes.fs :as fs]))
|
[me.raynes.fs :as fs]))
|
||||||
|
|
||||||
(defn imgurl->bytes [lovelybooks-url]
|
(defn imgurl->bytes [lovelybooks-url]
|
||||||
(-> (java.net.URL. lovelybooks-url)
|
(let [urls (-> (java.net.URL. lovelybooks-url)
|
||||||
html/html-resource
|
html/html-resource
|
||||||
(html/select [:div.bookcoverXXL :> :div :> :img])
|
(html/select [:div.cover-wrapper :> :div.cover :> :img.BookCover])
|
||||||
first
|
first
|
||||||
(get-in [:attrs :src])
|
(get-in [:attrs :srcset])
|
||||||
(http-client/get {:as :byte-array})
|
(str/split #" "))
|
||||||
:body))
|
url-to-fetch (last (filter #(re-matches #"http.+\.jpg" %) urls))
|
||||||
|
stream (http-client/get url-to-fetch {:as :byte-array})]
|
||||||
|
(:body stream)))
|
||||||
|
|
||||||
|
|
||||||
(defn encode-url-part [part]
|
(defn encode-url-part [part]
|
||||||
(java.net.URLEncoder/encode part "UTF-8"))
|
(java.net.URLEncoder/encode part "UTF-8"))
|
||||||
|
|
Loading…
Reference in a new issue