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
460
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Webスクレイピングをしよう
SIGMA1425
January 18, 2020
Other Decks in Programming
See All in Programming
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
200
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
350
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
570
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
Building a Meta Ray-Ban display app
akkeylab
0
180
Press start. Python's next generation.
willingc
PRO
3
110
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
150
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
290
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
500
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
100
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
260
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
360
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
400
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Paper Plane
katiecoart
PRO
2
53k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
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などに流すと喜ばれ る ¡ スクレイピングは素晴らしい!
ありがとうございました!