ウェブ雑記

tushuhei が奮闘する日記

引用している論文の被引用数を取得する

TeX で論文を書く際に、引用している論文がどの程度被引用数があるのかが気になることがあります。
そこで、Google Scholar から被引用数を取得するスクリプトを書いたので、メモ。
Google を日本語設定で使っているのが前提です。Pythonです。

get_citedby.py

# coding: utf8
from bs4 import BeautifulSoup
import re
import requests
import sys

for line in sys.stdin:
  match = re.search(r"^\s+title\s?=\s?{(.+)},\s+$", line)
  if not match: continue
  title = match.group(1)
  url = u"http://scholar.google.co.jp/scholar?q=%s"%title.replace(" ", "+")
  html = requests.get(url).text
  soup = BeautifulSoup(html)
  divs = soup.find_all("div", {"class": "gs_fl"})
  for div in divs:
    matches = re.search(u"引用元 (\d+)", div.text)
    if not matches: continue
    print u"%s\t%d"%(title, int(matches.group(1)))
    break

そして、

$ python get_citedby.py < references.bib

というふうに bib ファイルを標準入力で渡すと、

Determinants of successful website design: relative importance and recommendations for effectiveness 207
Impact of website information design factors on consumer ratings of web-based auction sites 61
Seven Pitfalls to Avoid when Running Controlled Experiments on the Web 26

というように論文のタイトルと被引用数が出力されます。

注意点

  • Google Scholar でタイトルで検索した際に、一番最初に表示される論文が対象の論文という前提で書いてます。