123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- # Access Scopus database
- #
- import requests
- import json
- from my_scopus import MY_API_KEY
- from my_scopus import ak, pdv, ufo, ufo_ips
- #
- # Get the last N publications of an given author list
- #
- # Arguments: list of scopus author ids (e.g. "35313939900")
- # Returns: list of scopus article ids ('SCOPUS_ID:0037368024')
- # The result can be used in the display functions like get_scopus_brief()
- #
- def get_scopus_list(author_list, opt='', n=5):
-
- if isinstance(author_list, list):
- #print "Length of author list %d" % len(author_list)
- query = ' OR '.join(['AU-ID('+au+')' for au in author_list])
- else:
- query = 'AU-ID('+author_list+')'
- if len(opt) > 0:
- query = query + " AND " + opt
-
- #print "Query: " + query
- url = ("http://api.elsevier.com/content/search/scopus?query="
- +query+ "&field=dc:identifier&count=" + str(n))
- #print "URL: " + url
- resp = requests.get(url,
- headers={'Accept':'application/json',
- 'X-ELS-APIKey': MY_API_KEY})
- #print resp
- results = resp.json()
- return [[str(r['dc:identifier'])] for r in results['search-results']["entry"]]
- def get_scopus_info(SCOPUS_ID):
- url = ("http://api.elsevier.com/content/abstract/scopus_id/"
- + SCOPUS_ID
- + "?field=article-number,title,publicationName,volume,issueIdentifier,"
- + "prism:pageRange,coverDate,article-number,doi,citedby-count,prism:aggregationType,url,identifier,description,authors,prism:issn")
- #print url
- resp = requests.get(url,
- headers={'Accept':'application/json',
- 'X-ELS-APIKey': MY_API_KEY})
- results = json.loads(resp.text.encode('utf-8'))
- #print resp
- print results
-
- fstring = '{authors}, {title}, {journal}, {volume}, {articlenum}, ({date}). {doi} (cited {cites} times).\n{abstract}\n\n'
- return fstring.format(authors=', '.join([au['ce:indexed-name'] for au in results['abstracts-retrieval-response']['authors']['author']]),
- title=results['abstracts-retrieval-response']['coredata']['dc:title'].encode('utf-8'),
- journal=results['abstracts-retrieval-response']['coredata']['prism:publicationName'].encode('utf-8'),
- volume=results['abstracts-retrieval-response']['coredata']['prism:volume'].encode('utf-8'),
- articlenum=(results['abstracts-retrieval-response']['coredata'].get('prism:pageRange') or
- results['abstracts-retrieval-response']['coredata'].get('article-number')).encode('utf-8'),
- date=results['abstracts-retrieval-response']['coredata']['prism:coverDate'].encode('utf-8'),
- doi='doi:' + results['abstracts-retrieval-response']['coredata']['prism:doi'].encode('utf-8'),
- cites=int(results['abstracts-retrieval-response']['coredata']['citedby-count'].encode('utf-8')),
- abstract=results['abstracts-retrieval-response']['coredata']['dc:description'].encode('utf-8'))
- #
- # Display a list of publications in plain text format
- #
- # Argement: scopus id of the publication
- #
- # Todo: Implement other formats (e.g. html, bibtex)
- # Format publications as articles, Title, Abstract
- #
- def get_scopus_brief(SCOPUS_ID, max_authors=1000):
- id = SCOPUS_ID
- if isinstance(id, list):
- id = id[0]
-
- url = ("http://api.elsevier.com/content/abstract/scopus_id/"
- + id
- + "?field=authors,article-number,title,publicationName,volume,issueIdentifier,"
- + "prism:pageRange,coverDate,article-number,doi,citedby-count,prism:aggregationType,url,identifier,description,prism:issn")
- #print url
- resp = requests.get(url,
- headers={'Accept':'application/json',
- 'X-ELS-APIKey': MY_API_KEY})
- results = json.loads(resp.text.encode('utf-8'))
- #print resp
- #print results
-
- coredata = results['abstracts-retrieval-response']['coredata']
-
- pub = ''
- authors = results['abstracts-retrieval-response']['authors']['author']
- #print "Number of authors: %d" %len(authors)
- if len(authors) > max_authors:
- return ''
- if len(authors) > 20:
- pub = pub + authors[0]['ce:indexed-name'] + ' et.al.: '
- else:
- pub = ', '.join([au['ce:indexed-name'] for au in authors]) + ': '
- try:
- if coredata.get('dc:title'):
- pub = pub + coredata.get('dc:title').encode('utf-8')
- except ValueError:
- print "!!! Error encoding title of publication !!!"
- #print coredata.get('dc:title')
- pub = pub + coredata.get('dc:title')
- if coredata.get('prism:publicationName'):
- pub = pub + ', ' + coredata.get('prism:publicationName').encode('utf-8')
- if coredata.get('prism:volume'):
- pub = pub + ', ' + coredata.get('prism:volume').encode('utf-8')
- if coredata.get('prism:issueIdentifier'):
- pub = pub + ', ' + coredata.get('prism:issueIdentifier').encode('utf-8')
-
- if coredata.get('prism:coverDate'):
- pub = pub + ' (' + coredata.get('prism:coverDate').encode('utf-8') + ') '
- if coredata.get('prism:pageRange'):
- pub = pub + coredata.get('prism:pageRange').encode('utf-8')
- elif coredata.get('article-number'):
- pub = pub + coredata.get('article-number').encode('utf-8')
- if coredata.get('prism:doi'):
- pub = pub + ', doi:' + coredata.get('prism:doi').encode('utf-8')
- if coredata.get('citedby-count'):
- pub = pub + ' (cited ' + coredata.get('citedby-count').encode('utf-8') + ' times)'
- pub = pub + '.\n'
- return pub
- # What kind of lists are interesting for a group website?
- # Organisation:
- #
- # Latest publications | Contact person
- # List of 3-5 with titles first
- # First lines of the abtract | Events:
- # Number of citations | Upcoming event
- # (Blog format)
- #
- # Lately cited papers | Featured publications
- # List of 3-5 papers updated cites|
- # in the last N month
- # Format: Blog
- #
- #
- # List of the latest N publications (N = 3-5)
- # List of the latest publications without big collaboration papers?
- # List of collaboration papers
- # List of publication of the last N month (N = 6-12)
- # List split by sub groups
- # List of all publication of one year, that can be selected
- # List of featured publications (selected by a list of Scopus-Ids / or Blog with Scopus-Id)
- # Problem: If the people are in too many differnent projects
- # How to list only this ones of a certain topic?
- # Is there a subgroup, that is only involved in one project?
- # Try: Leave out ak, csa, we, baumbach, etc?
- #print "LUMINEU 0\u03bd2\u03b2 project".encode('utf-8')
- # get number of publications?
- # order by date?
- # limit to certain interval
- #
- # Save publications with their number of citations in JSON file of SQLITE database?!
- # List of newly cited publications
- #
- resp = requests.get("http://api.elsevier.com/content/author?author_id="+ak+"&view=metrics",
- headers={'Accept':'application/json',
- 'X-ELS-APIKey': MY_API_KEY})
- #print resp
- #print json.dumps(resp.json(),
- # sort_keys=True,
- # indent=4, separators=(',', ': '))
- #print get_scopus_info('SCOPUS_ID:0037368024')
- #publist = get_scopus_list(ak)
- #publist = get_scopus_list([ak,ak2], 'PUBYEAR = 2014', 30)
- #publist = get_scopus_list(pdv, 'PUBYEAR = 2015', 30)
- #publist = get_scopus_list(ufo_ipe, 'PUBYEAR = 2015', 30)
- #publist = get_scopus_list(ufo_ips, 'PUBYEAR = 2015', 30)
- # Exclude authors?
- publist = get_scopus_list(pdv, 'NOT AU-ID(7006284555)', 10)
- # Author ausschliessen - black list !!!
- #
- # Display the result
- #
- print "Number of publications: %d" % len(publist)
- for pub in publist:
- print get_scopus_brief(pub,10000)
- # Test printing functions
- #print publist[2][0]
- #print get_scopus_info('SCOPUS_ID:0037368024')
- #print get_scopus_info(publist[2][0])
- # Merge publications
- # Search for all publications? Elimintate dublicates
- # Format abstract
- #
- # There seem to be also preformatted output?
- # Is output in BibTeX possible?
- #
- # Impact-Factor of the journal?
- # Queries:
- # List all publications
- # List the lastest publications
- # List list publications of the group wo double entries
- # List latest pubs
- # List publication with higest citation count
- # List publication in magazines with highest impact value
- # Print collaborator network of institutions
- # Print list of collaborations wo large collabs
- #
|