-
Notifications
You must be signed in to change notification settings - Fork 0
/
PeerReviewChecker.py
74 lines (55 loc) · 1.6 KB
/
PeerReviewChecker.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
import json
import re
import random
import pickle
import time
from tqdm import tqdm
import random
import urllib
from kora.selenium import wd
arxiv_base_url = 'https://arxiv.org/abs/'
semantic_base_url = 'https://www.semanticscholar.org/search?q='
semantic_suffix = '&sort=relevance'
article_id = ''
# generate arxiv url
arxiv_url = arxiv_base_url + article_id
print(arxiv_url)
# to remove extra id appended to title
clean_id = '['+article_id+'] '
clean_len = len(clean_id)
# load page via selenium
wd.get(arxiv_url)
time.sleep(1)
# get title from selenium
title_element = wd.title
# clean the title
title = title_element[clean_len:]
print('\n'+title)
# convert title to query - url encode
query_title = urllib.parse.quote(title, safe='')
# construct URL for semantic scholar
query = semantic_base_url + query_title + semantic_suffix
print('\n'+query)
# load semantic scholar - sorted results
wd.get(query)
time.sleep(1)
# get list of papers
element_papers_links = wd.find_elements_by_xpath('//a[@class="flex-row cl-paper-view-paper"]')
print(len(element_papers_links))
# get the first result
element_papers_first = element_papers_links[0]
# get conference/arxiv paper URL
paper_link = element_papers_first.get_attribute('href')
# get link button class
paper_class = element_papers_first.find_element_by_class_name('cl-button__label')
# get publishing details text
paper_publish_text = paper_class.text
print('Results: \n')
print(paper_link)
print('\n')
print(paper_publish_text)
# Handle the results according to your use-case
if 'arxiv' in paper_link:
print('Arxiv Paper')
else:
print('Peer-reviewed paper')