-
Notifications
You must be signed in to change notification settings - Fork 1
/
scopus_citations_miner_v2.py
120 lines (95 loc) · 3.65 KB
/
scopus_citations_miner_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import csv
from selenium import webdriver
from time import sleep
import pandas as pd
import math
driver = webdriver.Chrome(executable_path='c:/chromedriver')
# [EDIT] dataframe from input xlsx
df = pd.read_excel('')
# [EDIT] login information to Scopus.com
u = ''
p = ''
driver.get('https://www.scopus.com')
driver.find_element_by_xpath('//*[@id="signin_link_move"]').click()
driver.find_element_by_xpath('//*[@id="bdd-email"]').send_keys(u)
driver.find_element_by_xpath('//*[@id="bdd-elsPrimaryBtn"]').click()
driver.find_element_by_xpath('//*[@id="bdd-password"]').send_keys(p)
driver.find_element_by_xpath('//*[@id="bdd-elsPrimaryBtn"]').click()
for index, row in df.iterrows():
row = row.copy()
try:
scopus_ids = str(row['Scopus ID']).split('; ')
links = ['http://www.scopus.com/authid/detail.url?authorId=%s' %
scopus_id for scopus_id in scopus_ids]
NUM_PUBS = 0
CITES = 0
HINDEX = 0
HINDEX_SELF = 0
for i in range(0, len(links)):
link = links[i]
scopus_id = scopus_ids[i]
driver.get(link)
sleep(5)
# check id
try:
info = driver.find_element_by_class_name('authId')
info = info.text.strip().split('\n')[0].split(': ')[1]
except:
pass
# 01 get pubs (ok)
try:
num_pubs = int(driver.find_element_by_id(
'authorDetailsDocumentsByAuthor').find_element_by_class_name('panel-body').text.split('\n')[0])
except:
num_pubs = 0
pass
# 02 get citations (ok)
try:
cites = int(driver.find_element_by_id('totalCiteCount').text)
except:
cites = 0
pass
# 03 hindex (ok)
try:
hindex = driver.find_element_by_id('authorDetailsHindex')
hindex = int(hindex.text.strip().split('\n')[2])
if hindex > HINDEX:
HINDEX = hindex
except:
hindex = 0
pass
# 05 getting h-index w/o self citation
try:
hindex_self = driver.find_element_by_xpath(
'//*[@id="authorDetailsHindex"]/div[2]/button').click()
hindex_self = driver.find_element_by_xpath(
'//*[@id="hindexCheckboxes"]/div[1]/label').click()
hindex_self = driver.find_element_by_xpath(
'//*[@id="updateGraphButton_submit1"]').click()
sleep(6)
hindex_self = int(driver.find_element_by_xpath(
'//*[@id="analyzeSourceTitle"]/span[2]').text)
if hindex_self > HINDEX_SELF:
HINDEX_SELF = hindex_self
except:
hindex_self = 0
pass
# throw a warning if the scopus link get redirect somewhere else
if scopus_id != info:
print('[WARN] SCOPUS_ID_REDIRECT: %s' % scopus_id)
else:
NUM_PUBS += num_pubs
CITES += cites
df.loc[index, 'Num Pub'] = NUM_PUBS
df.loc[index, 'Citations'] = CITES
df.loc[index, 'h-index'] = HINDEX
df.loc[index, 'h-index_self'] = HINDEX_SELF
except:
pass
driver.close()
driver.quit()
# output
out_file = 'out.xlsx'
writer = pd.ExcelWriter(out_file)
df.to_excel(writer, sheet_name='out')
writer.save()