Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Webスクレイピング
Search
株式会社Curious Vehicle
February 07, 2025
0
28
Webスクレイピング
株式会社Curious Vehicle
February 07, 2025
Tweet
Share
More Decks by 株式会社Curious Vehicle
See All by 株式会社Curious Vehicle
ElasticsearchのHA構成について
curicle
0
2
機械学習で絶対音感になりたかった
curicle
0
5
BQにおけるSQLアンチパターンとslot消費削減策
curicle
0
10
VibeKanbanについて
curicle
0
5
"バーチャル宮本さん"を作ってみた
curicle
0
5
"バーチャル宮本さん” 本番デプロイ編
curicle
0
7
最近課金しているAIサービスについて
curicle
0
11
Pub_Sub
curicle
0
4
音声認識について
curicle
0
7
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.7k
Navigating Team Friction
lara
191
16k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
It's Worth the Effort
3n
187
29k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.3k
Designing for humans not robots
tammielis
254
26k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
The Language of Interfaces
destraynor
162
25k
Side Projects
sachag
455
43k
A better future with KSS
kneath
240
18k
RailsConf 2023
tenderlove
30
1.3k
Transcript
第46回勉強会 Webスクレイピング 2019/06/25 安齋 佑司 1 — Curious Vehicle Confidential
—
もくじ • Webスクレイピングとは • 環境構成 • 処理概要 • 実行結果 •
まとめ 2 — Curious Vehicle Confidential —
Webスクレイピングとは インターネットから情報を抽出すること — Curious Vehicle Confidential — 3
Webスクレイピングとは • 用途 1. 競合分析 2. データ補充 3. データマイニング —
Curious Vehicle Confidential — 4
Webスクレイピングとは • スクレイピングの流れ 1. Webクローリング 2. 抽出対象箇所の情報抽出 (ノイズを削除) 3. 整形
— Curious Vehicle Confidential — 5 今回は、ある目的でとあるWebサイトから情報を抽出したので その方法と結果を紹介します。
環境構成 1. インターネットに接続した端末 (クラウド推奨) 2. crawler4j (Java) 3. 整形用のスクリプト (Python)
4. 分析用ライブラリ (Python, gensim) — Curious Vehicle Confidential — 6 クローリングされたサイトからアクセスが遮断されても 影響が出ないようにクラウドからクローリングをかけている。 ※ サイト側からはDoSと見分けがつかないため。
処理概要 1. クローリング 2. 情報抽出 3. クレンジング 4. 分析 —
Curious Vehicle Confidential — 7
処理概要 1. クローリング https://github.com/yasserg/crawler4j — Curious Vehicle Confidential — 8
処理概要 — Curious Vehicle Confidential — 9 テキスト情報を取得するため More Examples
の Basic crawler を利用した
処理概要 — Curious Vehicle Confidential — 10 テキスト情報を取得するため More Examples
の Basic crawler を利用した
処理概要 — Curious Vehicle Confidential — 11 並列数、インターバル、階層の深さ、最大取得ページ数、URLを設定
処理概要 — Curious Vehicle Confidential — 12 フィルタ情報を設定し、ファイルに出力する処理を追記
処理概要 — Curious Vehicle Confidential — 13 Installation に従って pom.xml
を記述して Maven でビルド (面倒)
処理概要 — Curious Vehicle Confidential — 14 プログラムを実行して目的のページ数が取得されるまで待つ 1秒インターバル、4並列 *1ページ表示にかかる時間
→ 2万ページを取得するまで放置した。
処理概要 2. 情報抽出 — Curious Vehicle Confidential — 15 使わずにタグの文字列で当てに行った
処理概要 2. 情報抽出 — Curious Vehicle Confidential — 16
処理概要 3. クレンジング — Curious Vehicle Confidential — 17 英語以外の言語のページを除外
(2万 → 13270に減少) コンテンツに混ざっているHTMLタグを除外
処理概要 3. クレンジング — Curious Vehicle Confidential — 18 文章から特徴を抽出するために、以下の情報を削除
• Stop words • 前置詞、接続詞、代名詞、数詞 など 単語の正規化 • 複数形を単数形に寄せる • 原形に寄せる ※ この辺は vi マクロでコードを書いたが NLP系のライブラリを使えばよかった
処理概要 4. 分析 — Curious Vehicle Confidential — 19 各ページのトピックを
LDAで出力
処理概要 4. 分析 — Curious Vehicle Confidential — 20 全ページから
Word Count を出力
実行結果 — Curious Vehicle Confidential — 21 LDA 1コンテンツ1行でトピックを出力
実行結果 — Curious Vehicle Confidential — 22 Word Count 頻度順に出力
まとめ • WebスクレイピングはWeb上の資源を抽出できる • クローリングはサイトに迷惑をかけないように • 他の方法もあるので今回の方法が最善ではない • やってみると発見があるから面白い —
Curious Vehicle Confidential — 23
おしまい ご清聴ありがとうございました。 — Curious Vehicle Confidential — 24