Beispiel #1
0
 def __get_abstract(self, identifier, identifier_type):
     url = "https://api.elsevier.com/content/abstract/" + identifier_type + "/" + identifier
     json_data = None
     try:
         json_data = utils.get_json_from_url(url, self.__get_header())
     except urllib2.HTTPError as e:
         print "Error getting abstract"
         utils.print_http_error(e)
         raise e
     return json_data
Beispiel #2
0
 def __get_affiliation(self, identifier, identifier_type):
     url = "https://api.elsevier.com/content/affiliation/" + identifier_type + "/" + identifier
     json_data = None
     try:
         json_data = utils.get_json_from_url(url, self.__get_header())
     except urllib2.HTTPError as e:
         print "Error retrieving affiliation information"
         utils.print_http_error(e)
         raise e
     return json_data
Beispiel #3
0
 def get_journal_metrics(self, issn, initial_year=1900, end_year=2100):
     url = ''.join(
         ("https://api.elsevier.com/content/serial/title?issn=" + issn,
          "&view=", self.VIEW_STANDARD.type,
          "&date=" + str(initial_year) + "-" + str(end_year)))
     json_data = None
     try:
         json_data = utils.get_json_from_url(url, self.__get_header())
     except urllib2.HTTPError as e:
         print "Error retrieving journal metrics -> " + url
         utils.print_http_error(e)
         raise e
     return json_data
Beispiel #4
0
 def __init__(self, api_key, choice=None, tunnel_url=None, tunnel_port=None):
     if tunnel_url and tunnel_port:
         ssh_tunnel.init_proxy(tunnel_url, tunnel_port)
     self.api_key = api_key
     url = 'https://api.elsevier.com/authenticate?platform=SCOPUS'
     if choice:
         url += '&choice=' + choice
     header = {
         'Accept': 'application/json',
         'X-ELS-APIKey': api_key
     }
     try:
         res = utils.get_json_from_url(url, header)
         self.token = res['authenticate-response']['authtoken']
     except urllib2.HTTPError as e:
         print "Error authenticating"
         utils.print_http_error(e)
         exit(-1)
Beispiel #5
0
    def scopus_search(self,
                      query,
                      view=VIEW_STANDARD,
                      suppress_nav_links=False,
                      date=None,
                      start=0,
                      count=25,
                      field=None,
                      sort=None):
        if not isinstance(query, Query):
            print(
                "Query parameter must be set and should be an instance of Query class. Exiting..."
            )
            exit(-1)
        if not isinstance(view, View):
            print(
                "View parameter must be an instance of inner View class. Check attributes starting with View_* in "
                "ElsClient object. "
                "Program will exit...")
            exit(-1)
        if not isinstance(suppress_nav_links, bool):
            print(
                "suppress_nav_links parameter should be either True or False. Exiting..."
            )
            exit(-1)
        query_quoted = urllib.quote_plus(query.get_query())
        url = "https://api.elsevier.com/content/search/scopus?" \
              "view=" + view.type + \
              "&query=" + query_quoted + \
              "&suppressNavLinks=" + str(suppress_nav_links).lower()
        if date:
            url += "&date=" + date
        if field:
            url += "&field=" + field
        url += "&start=" + str(start) + "&count=" + str(count)
        if sort:
            if not isinstance(sort, list) and not isinstance(sort, tuple):
                print "Sort parameter must be either a list or tuple of a maximum of 3 Sort elements. Program will exit..."
                exit(-1)
            if len(sort) > 3:
                print "Sort parameter has a maximum of 3 elements. Program will exit..."
                exit(-1)
            l = []
            for s in sort:
                if not isinstance(s, Sort):
                    print(
                        "All elements of sort parameter must be of Sort class. Check attributes starting with Sort_* "
                        "in ElsClient object. Program will exit...")
                    exit(-1)
                l.append(s.type)
            sort_joined = ",".join(l)
            url += "&sort=" + sort_joined

        json_data = None
        try:
            json_data = utils.get_json_from_url(url, self.__get_header())
        except urllib2.HTTPError as e:
            print "Error while retrieving information from SCOPUS:"
            utils.print_http_error(e)
            raise e

        return json_data