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
Webスクレイピングをしよう
Search
SIGMA1425
January 18, 2020
Programming
0
440
Webスクレイピングをしよう
SIGMA1425
January 18, 2020
Tweet
Share
Other Decks in Programming
See All in Programming
はじめてのMaterial3 Expressive
ym223
2
900
知っているようで知らない"rails new"の世界 / The World of "rails new" You Think You Know but Don't
luccafort
PRO
1
190
OSS開発者という働き方
andpad
5
1.7k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
310
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
640
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
440
アプリの "かわいい" を支えるアニメーションツールRiveについて
uetyo
0
280
Things You Thought You Didn’t Need To Care About That Have a Big Impact On Your Job
hollycummins
0
100
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
350
Navigating Dependency Injection with Metro
zacsweers
3
3.5k
Testing Trophyは叫ばない
toms74209200
0
890
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Unsuck your backbone
ammeep
671
58k
The Invisible Side of Design
smashingmag
301
51k
How to Ace a Technical Interview
jacobian
279
23k
RailsConf 2023
tenderlove
30
1.2k
Optimizing for Happiness
mojombo
379
70k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.1k
Making the Leap to Tech Lead
cromwellryan
135
9.5k
Transcript
Webスクレイピングをしよう 授業変更情報BOTの作成
自己紹介 ¡ SIGMA(@SIGMA_tkn) ¡ 苫小牧高専 情報系3年 ¡ ロボットテクノロジー部(いわゆるロボコン部) ¡ Pythonで画像解析
¡ 1年生にC言語の講習 ¡ 初めてのLT(がんばります)
初めてなので…
¡Webスクレイピングとは?
Webスクレイピングを一言で ¡ サイトから情報を抜き出す処理
スクレイピングの実用例 ¡ 天気予報のサイトからその日の天気を取り出す ¡ JRのサイトから運行情報を取り出す ¡ ニュースサイトからニュースを取り出す ¡ etc…
注意点 ¡ サイトによってはスクレイピングを禁止しているの もある ¡ 代表的なものとしてはTwitter
None
スクレイピングを利用して… ¡ 苫小牧高専のHPから授業変更を抜き出してみた
きっかけ ¡ ある日、たまたま授業変更を見忘れた
きっかけ 僕「まぁどうせ授業変更なんてないでしょ〜(フラグ)」
フラグ回収
None
使うライブラリ(Pythonを用いる) ¡ Requests →Webサイトの情報を取得する ¡ BeautifulSoup →Webサイトを解析する
None
基本的には… ¡ requests.getにURLを渡し、BeautifulSoupでパース処理 ¡ あとはテキスト属性のみ取り出して必要な情報のみ抜き 出したり、整形するなど
None
苫小牧高専HPの授業変更情報(自分のクラス)の データを取得する ↓ パースする ↓ <td>タグのみ抜き出す ↓ 「科目名」というキーワードがあれば授業変更を探索、 テキスト属性のみ抜き出す ↓
出力
実行結果
ラズパイのcrontabを用いて毎日、定時に実行 授業変更は毎日見たいので…
さらにクラスの人たちにも共有するために… 実行結果をクラスのSlackに出力
None
まとめ ¡ スクレイピングは簡単にできる ¡ 毎日、サイトを訪れる手間が省ける ¡ 他の人たちも見るような情報はSlackなどに流すと喜ばれ る ¡ スクレイピングは素晴らしい!
ありがとうございました!