LoginSignup
2
1
この記事誰得? 私しか得しないニッチな技術で記事投稿!

#03 J-STAGEから論文タイトルで検索をしてcsvファイルでDL

Posted at

はじめに

J-STAGEに建築学会の黄表紙も公開されるようになったので、都市計画論文集と並んで検索とかがしやすくなりました。ただし、既往研究をあさるときになかなかリストにしにくいと思っていた(コピペは面倒)ので、APIを使って楽に既往研究のリストを作ることができるようにしようと思ったのがきっかけ。

仕様は以下のHPに割と丁寧に書いてある。
https://www.jstage.jst.go.jp/static/pages/JstageServices/TAB3/-char/ja

APIは結局XMLを返してくるので、ブラウザでURLを入れてXMLをエクセルで加工としていたんだけどめんどくさくなってきたので以下のプログラムを作成。

プログラム

### 利用するライブラリのインポート
# インストールしてなければ
# !pip install xmltodict
import xmltodict
from collections import defaultdict
import pandas as pd
import requests as re

### APIからXMLの取得
# 検索対象にする雑誌(都市計画論文集→2185-0593、日本建築学会計画系論文集→1881-8161)
ISSN = "1881-8161"
# 検索ワード
word = '"立地適正化"'
# 取得するためののURL
URL = "https://api.jstage.jst.go.jp/searchapi/do?service=3&issn=" + ISSN + "&article=" + word
# 取得
result = re.get(URL)

### 取得データの加工(著者、年、タイトル、雑誌名、巻号、ページ数、doi)
xml_dict = xmltodict.parse(result.content)
data = defaultdict(list) 

# 取得データからリストに変換
for article in xml_dict["feed"]["entry"]:
  data["name"].append(article["author"]["ja"]["name"])
  data["pubyear"].append(article["pubyear"])
  data["title"].append(article["article_title"]["ja"])
  data["journal"].append(article["material_title"]["ja"])
  data["vol"].append(article["prism:volume"])
  data["No"].append(article["prism:number"])
  data["page_s"].append(article["prism:startingPage"])
  data["page_f"].append(article["prism:endingPage"])
  data["doi"].append(article["prism:doi"])

# データをデータフレームにしてpandasでcsvとして保存
df = pd.DataFrame.from_dict(data)
df.to_csv("result.csv")

検索ワードとISSNは適宜変更してください。

参考

・API仕様書
https://www.jstage.jst.go.jp/static/pages/JstageServices/TAB3/-char/ja
・J-STAGE WebAPIで「ポルノ」論文567本のデータを取得する【Python】
https://note.com/h_keisuke/n/n92c2396231cf

困りごと(今後解決したい)

・論文タイトルは取得できるが副題が取得できない。APIでは取得できなそう?

それでは

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