Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
How to scrape web contents in Clojure
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
ayato
January 09, 2016
Programming
99
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
How to scrape web contents in Clojure
ayato
January 09, 2016
More Decks by ayato
See All by ayato
マイクロサービス内で動くAPIをF#で書いている
ayato0211
1
1.6k
Clojureという言語が私逹にもたらしたもの
ayato0211
6
3.2k
3年間考え続けてきたWebアプリケーションにおけるテストの話
ayato0211
3
310
Re:REPL-Driven Development
ayato0211
3
1.4k
Meta Template Engine
ayato0211
2
1.2k
超変換! Hiccup data structure!!
ayato0211
2
670
About Integrant
ayato0211
0
610
Muscle Assert
ayato0211
0
330
Clojureを用いたWebアプリケーション開発
ayato0211
2
3.2k
Other Decks in Programming
See All in Programming
関数型プログラミングのメリットって何だろう?
wanko_it
0
140
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
160
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
270
どこまでゆるくて許されるのか
tk3fftk
0
410
Performance Engineering for Everyone
elenatanasoiu
0
260
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
0
410
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
110
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
120
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Writing Fast Ruby
sferik
630
63k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
A designer walks into a library…
pauljervisheath
211
24k
A Tale of Four Properties
chriscoyier
163
24k
Crafting Experiences
bethany
1
210
AI: The stuff that nobody shows you
jnunemaker
PRO
8
770
Designing Powerful Visuals for Engaging Learning
tmiket
1
440
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
600
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Transcript
)PXUPTDSBQF XFCDPOUFOUT JO$MPKVSF !@BZBUP@Q
͋ͽʔ $MPKVSJBO $ZCP[V4UBSUVQT *OD
8IBUJTXFCTDSBQJOH ΣϒεΫϨΠϐϯά 8FCTDSBQJOH ͱɺ ΣϒαΠτ͔ΒใΛநग़͢Δ ίϯϐϡʔλιϑτΣΞٕज़ͷ͜ͱɻ CZXJLJQFEJB
1SPCMFNT 8FCίϯςϯπߏʹ͍ۙܗΛ͍ͯ͠Δ ࣅ͍ͯΔϖʔδ͕ࢁ͋Δ͕ඍົʹҧ͏ ߏΛ୧Δ࠶ؼతͳίʔυΛॻ͘ඞཁ͕͋Δ ͍͍ͩͨ໘͍͘͞
4LZTDSBQFS ߏΛ࠶ؼతʹ୧ͬͯ͘ΕΔ ϖʔδͷλΠϓຖʹॲཧํ๏͚ͩॻ͚͍͍ ԆγʔέϯεΛฦͯ͘͠ΕΔ Ωϟογϡػߏ͕͍͍ͭͯΔ εΫϨΠϐϯά෦&OMJWFґଘ IUUQTHJUIVCDPNOBUIFMMTLZTDSBQFS
(defn seed [username from until] (let [url (str "http://twilog.org/" username)]
[{:username username :from from :until until :url url :processor ::user-page}])) (s/defprocessor user-page :cache-template "twilog/:username" :process-fn (fn [res {:keys [username]}] (let [not-registered (seq (html/select res [:div.box-info.box-icon])) not-found (seq (html/select res [:div.box-attention.box-icon]))] (cond not-registered [{:msg "This account was not registered."}] not-found [{:msg "This account was not found."}] :else [{:url (str "http://twilog.org/" username "/archives") :processor ::archives-page}])))) &YBNQMF
(defn scrape [username & [{:as options :keys [html-cache processed-cache from
until] :or {html-cache true processed-cache true from "00000000" until "99999999"}}]] (let [handler (create-handler identity options)] (handler (s/scrape (seed username from until) :html-cache html-cache :processed-cache processed-cache)))) &YBNQMF
$PODMVTJPO 4LZTDSBQFSΛ͏ͱͤʹͳΕΔ $MPKVSF࠷ߴʂ
Enjoy Clojure