How to use scholarly - 10 common examples

To help you get started, we’ve selected a few scholarly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chintu619 / citation-sorted-arxiv-slack-bot / arXiv_bot.py View on Github external
def getAuthorCitations(author):
#    print(author)
    # check if author has initials in name
    author_name_without_initials = author.split(' ')[0] + ' ' + author.split(' ')[-1]
    if author != author_name_without_initials:
        flag_authorHasInitialsInName = True
    else: flag_authorHasInitialsInName = False

    search_query = scholarly.search_author(author)
    try: # check if author is listed in google scholar
        author_stats = next(search_query)
        try: # if multiple people exist with same name, skip author
            next(search_query); author_count = 2
        except: author_count = 1
    except:
        author_count = 0

    # if author is uniquely identified in scholar, get citation count
    if author_count == 1:
        try: author_citation_count = author_stats.citedby
        except: author_citation_count = 0
    elif (author_count == 0) and flag_authorHasInitialsInName:
        author_citation_count = getAuthorCitations(author_name_without_initials)
    else:
        author_citation_count = 0
github chintu619 / citation-sorted-arxiv-slack-bot / webutils.py View on Github external
def getAuthorCitations(author):
#    print(author)
    # check if author has initials in name
    author_name_without_initials = author.split(' ')[0] + ' ' + author.split(' ')[-1]
    if author != author_name_without_initials:
        flag_authorHasInitialsInName = True
    else: flag_authorHasInitialsInName = False

    search_query = scholarly.search_author(author)
    try: # check if author is listed in google scholar
        author_stats = next(search_query)
        try: # if multiple people exist with same name, skip author
            next(search_query); author_count = 2
        except: author_count = 1
    except:
        author_count = 0

    # if author is uniquely identified in scholar, get citation count
    if author_count == 1:
        try: author_citation_count = author_stats.citedby
        except: author_citation_count = 0
    elif (author_count == 0) and flag_authorHasInitialsInName:
        author_citation_count = getAuthorCitations(author_name_without_initials)
    else:
        author_citation_count = 0
github xLeitix / slack_scholar / scholar-slack / scholar / backend / handler.py View on Github external
def query_scholar_for_author_profile(author):

    try:
        _author = next(scholarly.search_author(author))
    except:
        return "Ooopsie. Maybe we ran over the request limit?"

    if _author == None:
        return "Did not find a profile for %s" % author

    resp_str = ""
    resp_str += (_author.name + "\n")
    resp_str += (_author.affiliation + "\n")
    for interest in _author.interests:
        resp_str += (interest + ' - ')
    resp_str += "\n"
    resp_str += ("https://scholar.google.ch/citations?user=" + _author.id)

    return resp_str
github pelednoam / mmvt / src / misc / google_scholar.py View on Github external
def get_author(author_name):
    # Retrieve the author's data, fill-in, and print
    search_query = scholarly.search_author(author_name)
    author = next(search_query).fill()
    return author
github jdumas / autobib / providers.py View on Github external
def scholarly_query(authors, title):
    """
    Query Google Scholar database.

    Args:
        authors (list): a list of strings for up the first authors last names.
        title (str): the title of the article.

    Returns:
        A record (dict) of the bibtex entry obtained from Google Scholar.
    """
    query = ' '.join(authors) + ' ' + title
    search_query = scholarly.search_pubs_query(query)
    try:
        res = next(search_query)
    except StopIteration:
        return None
    res.fill()
    if 'abstract' in res.bib:
        del res.bib['abstract']

    # Post-process title
    res.bib['title'] = re.sub('\\.*$', '', res.bib['title'])

    print('S: ' + nomenclature.gen_filename(res.bib))
    return res.bib
github perrette / papers / papers / extract.py View on Github external
def fetch_bibtex_by_fulltext_scholar(txt, assess_results=True):
    import scholarly
    scholarly._get_page = _get_page_fast  # remove waiting time
    logger.debug(txt)
    search_query = scholarly.search_pubs_query(txt)

    # get the most likely match of the first results
    results = list(search_query)
    if len(results) > 1 and assess_results:
        maxscore = 0
        result = results[0]
        for res in results:
            score = _scholar_score(txt, res.bib)
            if score > maxscore:
                maxscore = score
                result = res
    else:
        result = results[0]

    # use url_scholarbib to get bibtex from google
    if getattr(result, 'url_scholarbib', ''):
github pelednoam / mmvt / src / misc / google_scholar.py View on Github external
def get_citations_url_scholarbibs_by_publication_title(publication_title):
    bibtex_refs = []
    search_query = scholarly.search_pubs_query(publication_title)
    try:
        pub = next(search_query).fill()
        # pub = pub.fill()
        citations = list(pub.get_citedby())
        # citation = get_citatations()
        print('{} citatations for {}'.format(len(citations), pub.bib['title']))
        for citation in citations:
            bibtex_refs.append(citation.url_scholarbib)
        return bibtex_refs
    except:
        print('Can\'t find "{}"!'.format(publication_title))
        return []
github perrette / papers / papers / extract.py View on Github external
# get the most likely match of the first results
    results = list(search_query)
    if len(results) > 1 and assess_results:
        maxscore = 0
        result = results[0]
        for res in results:
            score = _scholar_score(txt, res.bib)
            if score > maxscore:
                maxscore = score
                result = res
    else:
        result = results[0]

    # use url_scholarbib to get bibtex from google
    if getattr(result, 'url_scholarbib', ''):
        bibtex = scholarly._get_page(result.url_scholarbib).strip()
    else:
        raise NotImplementedError('no bibtex import linke. Make crossref request using title?')
    return bibtex
github perrette / papers / papers / extract.py View on Github external
def fetch_bibtex_by_fulltext_scholar(txt, assess_results=True):
    import scholarly
    scholarly._get_page = _get_page_fast  # remove waiting time
    logger.debug(txt)
    search_query = scholarly.search_pubs_query(txt)

    # get the most likely match of the first results
    results = list(search_query)
    if len(results) > 1 and assess_results:
        maxscore = 0
        result = results[0]
        for res in results:
            score = _scholar_score(txt, res.bib)
            if score > maxscore:
                maxscore = score
                result = res
    else:
        result = results[0]
github chintu619 / citation-sorted-arxiv-slack-bot / scholarly.py View on Github external
def _search_scholar_soup(soup):
    """Generator that returns Publication objects from the search page"""
    while True:
        for row in soup.find_all('div', 'gs_or'):
            yield Publication(row, 'scholar')
        if soup.find(class_='gs_ico gs_ico_nav_next'):
            url = soup.find(class_='gs_ico gs_ico_nav_next').parent['href']
            soup = _get_soup(_HOST+url)
        else:
            break

scholarly

Simple access to Google Scholar authors and citations

Unlicense
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis