3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google Scholarのキーワード検索結果を引用数順に並べたリストを作成

Last updated at Posted at 2022-03-17

環境

Mac OS Big Sir
python version 3.9.5

やりたいこと

Google Scholarで文献を検索して、引用数が多い順に並び替えたリストを作成する。

使用するプログラムの準備

sort-google-scholarはWittmannF氏によりgithub上に公開されているプログラムで、python環境があれば実行可能です。

参照
https://github.com/WittmannF/sort-google-scholar

Pythonのバージョンの確認

Python3が必要なので、バージョン確認。以前にAnancondaから入れてました。

Terminal
% python --version
Python 3.9.5

Python3がない場合は以下から入手
https://www.anaconda.com/products/individual

sort-google-scholarをgithubからダウンロード

Terminal
% git clone https://github.com/WittmannF/sort-google-scholar.git

sort-google-scholarフォルダ確認してみた。

sort-google-scholarを実行

Downloadsディレクトリ直下にあるsort-google-scholarへ移動して中身確認

Terminal
% cd ~/Downloads/sort-google-scholar 
% ls
README.md			sort-google-scholar-V1
Test_sortgs_py_on_Colab.ipynb	sortgs.py
examples			test
requirements.txt

README.mdファイルの中に使い方が書いてありました。

README.md
Usage of sortgs.py
usage: sortgs.py [-h] [--kw KEYWORD] [--sortby SORTBY] [--nresults NRESULTS]
                 [--csvpath CSVPATH] [--notsavecsv] [--plotresults]
                 [--startyear STARTYEAR] [--endyear ENDYEAR]

Example: $python sortgs.py --kw 'deep learning'

optional arguments:
  -h, --help            show this help message and exit
  --kw KEYWORD          Keyword to be searched. Default is 'machine learning'
                        Use double quote followed by simple quote to search 
			for an exact keyword. Example: "'exact keyword'"
  --sortby SORTBY       Column to be sorted by. Default is by the columns
                        "Citations", i.e., it will be sorted by the number of
                        citations. If you want to sort by citations per year,
                        use --sortby "cit/year"
  --nresults NRESULTS   Number of articles to search on Google Scholar.
                        Default is 100. (carefull with robot checking if value
                        is too high)
  --csvpath CSVPATH     Path to save the exported csv file. By default it is
                        the current folder
  --notsavecsv          By default results are going to be exported to a csv
                        file. Select this option to just print results but not
                        store them
  --plotresults         Use this flag in order to plot the results with the
                        original rank in the x-axis and the number of citaions
                        in the y-axis. Default is False
  --startyear STARTYEAR
                        Start year when searching. Default is None
  --endyear ENDYEAR     End year when searching. Default is current year

キーワード"DOHaD"で論文を検索して引用数順に並び替えたリストを作成。

Terminal
% python sortgs.py --kw "DOHaD"    
Traceback (most recent call last):
  File "/Users/YourName/Downloads/sort-google-scholar/sortgs.py", line 21, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

あれ、pythonパッケージ'matplotlib'が入っていなくてエラーになった。
必要なパッケージは、requirements.txtに記載されていたので確認。

Terminal
% cat requirements.txt 
requests
beautifulsoup4
pandas
matplotlib
selenium

インストール済パッケージの一覧表示させて、インストールが必要なパッケージを確認する。

Terminal
% pip list
Package                Version
---------------------- -------------------
argcomplete            1.12.3
bagit                  1.8.1
beautifulsoup4         4.10.0
brotlipy               0.7.0
・
・
・
(以下略)

requirements.txtに記載されているうちpip listで見当たらなかったパッケージをインストール。

Terminal
% pip install matplotlib
% pip install pandas

では、気を取りなおして。

Terminal
% python sortgs.py --kw "DOHaD"
Loading next 10 results
/Users/YourName/Downloads/sort-google-scholar/sortgs.py:252: UserWarning: Year not found for Could not catch title, appending 0
  warnings.warn("Year not found for {}, appending 0".format(title[-1]))
Loading next 20 results
Loading next 30 results
Loading next 40 results
Loading next 50 results
Loading next 60 results
Loading next 70 results
Loading next 80 results
Loading next 90 results
Loading next 100 results
                                               Author  ... cit/year
Rank                                                   ...         
18     L Czer, J Aragon, J Forrester, S Kar, S Dohad…  ...       26
16      L Mauri, D Jay, N Skeik, R Schwartz, S Dohad…  ...       83
41                 Silveira, AK Portella, MZ Goldani…  ...       17
21                       L Kraiss, T Carman, S Dohad…  ...       17
11            Gillman, D Barker, D Bier, F Cagampang…  ...       11
...                                               ...  ...      ...
34                                   Author not found  ...        0
23                                   Author not found  ...        0
12                                   Author not found  ...        0
5                                    Author not found  ...        0
111                                  Author not found  ...        0

[111 rows x 6 columns]

111 rows x 6 columnsの文献リストができたらしい。出力されたDOHaD.csvの中身確認。

Terminal
% ls
DOHaD.csv			Test_sortgs_py_on_Colab.ipynb	requirements.txt		sortgs.py
README.md			examples			sort-google-scholar-V1		test
% open DOHaD.csv 

スクリーンショット 2022-03-17 12.47.17.png

これは、便利すぎる。

追記

エクセルの文字化け解消方法は以下の通り。Rでtxtファイルに変換したあとエクセルでひらけばOK.

R
x <- read.csv("DOHaD.csv",header=T,encoding="UTF-8")
write.table(x,"DOHaD.txt",sep="\t",quote = F, fileEncoding = "CP932",col.names=NA)

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?