0
1

More than 5 years have passed since last update.

bashでwebスクレイピング

Posted at

bashでwebスクレイピング

スクリプト

scraping.sh
#! /bin/bash

SCRAPING_URL="http://"
SEARCH_WORD=""

# webページを取得
curl  --url ${SCRAPING_URL} -X GET |
  # 取得したhtmlを対象ワードでgrep
  grep $SEARCH_WORD |
  # 正規表現にマッチする行だけを抽出(ここでは<td align="right"で始まる行だけを抽出)
  sed -ne '/<td align="right"/,/<¥/td>/p' |
  # htmlタグを削除
  sed 's/<[^>]*>//g'

使いかた

SCRAPING_URLに対象URL
SEARCH_WORDに検索したいワードを指定

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1