-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetLatestIssueTest.py
More file actions
26 lines (21 loc) · 928 Bytes
/
Copy pathgetLatestIssueTest.py
File metadata and controls
26 lines (21 loc) · 928 Bytes
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
import requests
from lxml import etree
def get_latest_issue(issn, api_key):
headers = {
'Accept':'application/xml',
'X-ELS-APIKey': api_key
}
response = requests.get(f"https://api.elsevier.com/content/search/scopus?query=ISSN({issn})", headers=headers)
root = etree.fromstring(response.content)
# Extract the latest volume number
latest_volume = None
for entry in root.xpath('//atom:entry', namespaces={'atom': 'http://www.w3.org/2005/Atom'}):
volume = entry.find('{http://prismstandard.org/namespaces/basic/2.0/}volume')
if volume is not None:
latest_volume = volume.text
break # Assuming the first entry is the latest
return latest_volume
# Usage
api_key = '1788986f6b20d9f6fe6115c588a06023' # Replace with your actual API key
issn = '0024-3841' # Replace with the ISSN you're interested in
print(get_latest_issue(issn, api_key))