-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstracts.py
34 lines (26 loc) · 1 KB
/
Abstracts.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
from Mylogging import logging
import json
from Maltego2 import *
from mendeley import Mendeley
from tokens import *
def trx_abstracts(m):
TRX = MaltegoTransform()
doi=m.getProperty("DOI")
if not doi:
TRX.addUIMessage('A DOI is needed to perform this search. Please run "Search on Crossref" and, if a DOI is found, try again here')
return TRX.returnOutput()
client_id=Tokens.MendeleyID
client_secret = Tokens.MendeleySecret
mendeley = Mendeley(client_id, client_secret=client_secret)
auth = mendeley.start_client_credentials_flow()
session = auth.authenticate()
try:
abstract = session.catalog.by_identifier(doi=doi).abstract
except:
TRX.addUIMessage( "Cannot find document on Mendeley")
else:
new = TRX.addEntity("me.Article", title)
new.addProperty("abstract","Abstract", 'loose', abstract.encode('utf-8'))
TRX.addUIMessage(abstract)
logging(TRX.returnOutput(),m.Maltegoxml)
return TRX.returnOutput()