LoginSignup
4
2

More than 5 years have passed since last update.

サイト内の全ページのFacebookのogデータを一括で更新するスクリプト

Last updated at Posted at 2016-10-12

以前、「複数ページのFacebookのogデータを一括で更新するスクリプト」という記事で、og_scrapeというスクリプトを作って公開していましたが、ベースとなるURL(サイトのトップページなど)を一つ渡すとwgetを使ってサイト内のページリストを出力してくれるスクリプトを作り、内部でこれを呼び出すことで、引数にベースURLを渡すだけで一括更新してくれるようにしてみました(自分なりにUnix的発想1にもとづいたつもり)。

og_scrape
サイト内の全ページのFacebookのogデータを一括で更新するスクリプト

page_list
トップページのURLからリンクを辿ってサイト内の全ページのリストを取得するスクリプト

上記の2つをダウンロードして、仮にデスクトップに保存した場合、こんな感じで使います。

はじめに実行権限を与えておいてください。

$ cd ~/Desktop
$ chmod +x ./og_scrape
$ chmod +x ./page_list

og_scrape

ヘルプの表示。

$ ./og_scrape -h
Usage:
  og_scrape [-u ]
  og_scrape   ...

Description:
  Facebook og data bulk scraping

Options:
  -u ARG
  -h

Dependencies:
  - page_list (https://github.com/naokazuterada/dotfiles/blob/master/functions/page_list)

使い方。

$ ./og_scrape -u http://hoge.com

一応、以前のように引数にURLを指定して渡すこともできます。

$ ./og_scrape http://hoge.com http://hoge.com/about.html http://hoge.com/contact.html

page_list

og_scrapeの内部で使っているpage_listも、ページ一覧を作りたい時などに便利だと思います。
dオプションでリストのデリミッター(区切り文字)も指定できます。デフォルトは改行です。

$ ./page_list -u http://hoge.com
http://hoge.com/
http://hoge.com/about.html
http://hoge.com/contact.html

$ ./page_list -u http://hoge.com -d ','
http://hoge.com/,http://hoge.com/about.html,http://hoge.com/contact.html

$ ./page_list -u http://hoge.com -d ' '
http://hoge.com/ http://hoge.com/about.html http://hoge.com/contact.html

ヘルプの表示。

$ ./page_list -h
Usage:
  page_list [-u <base_url>] [-d <delimitter>] [-h]

Description:
  Get list of page urls from base_url.
  Delimitter is optional (default is linebreak)

Options:
  -u ARG *
  -d ARG
  -h

Dependencies:
  - wget

いずれも動作はMacでしか確認しておらず、それ以外の動作保証はしてません。


この記事は2015.3.28にこちらのURLで公開していた内容を移行しました。


  1. “一つのことを行い、またそれをうまくやるプログラムを書け。”という有名なやつです。うまくやってるのかどうかは自信ないですが…。UNIX哲学 

4
2
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
4
2