<jupyter_start><jupyter_text>Google Scholar<jupyter_code># Prepare scholar extractor
querier = scholar.ScholarQuerier()
settings = scholar.ScholarSettings()
settings.set_citation_format(scholar.ScholarSettings.CITFORM_BIBTEX)
querier.apply_settings(settings)
def submit(author, keyphrase):
    query = scholar.SearchScholarQuery()
    query.set_author(author)
    query.set_phrase(keyphrase)
    query.set_num_page_results(RES_LIMIT)
    querier.send_query(query)
    results = scholar.json(querier)
    return results
author = "fodor"
phrase = "language"
data<jupyter_output><empty_output><jupyter_text>Scopus API<jupyter_code>url = "http://api.elsevier.com/content/search/scopus"
key = '23096dfc3e1a8d87504a227fb4314c9f'
def scopus_submit(author, phrase):
    query = re.sub("\s+", "\+", phrase)
    if author != "":
        author = "AUTH%28{}%29".format(re.sub("\s+", "\+", author))
        query = "{}+{}".format(author, query)
    view = "STANDARD"
    count = "10"
    r = requests.get("{}?query={}&apiKey={}&view={}&count={}".format(url, query, key, view, count))
    return r.json()
data = scopus_submit(author, phrase)
len(data['search-results']['entry'])
data['search-results']['entry'][1]['prism:doi']
doi = data['search-results']['entry'][6]['prism:doi']
doi<jupyter_output><empty_output><jupyter_text>Get article from Unpaywall<jupyter_code># http://unpaywall.org/api/v2
def unpaywall_check(doi):
    r = requests.get("https://api.oadoi.org/v2/{}?email=<EMAIL>".format(doi))
    response = r.json()
    return response['is_oa']
# https://stackoverflow.com/questions/15644964/python-progress-bar-and-downloads

def unpaywall_download(doi, save="test.pdf"):
    r = requests.get("https://api.oadoi.org/v2/{}?email=<EMAIL>".format(doi))
    response = r.json()
    for loc in response['oa_locations']:
        if loc['url_for_pdf']:
            dl = requests.get(loc['url_for_pdf'])
            with open(save, 'wb') as output:
                output.write(dl.content)
            return True
        else:
            continue
    return False
unpaywall_check(doi)
unpaywall_download(doi)<jupyter_output><empty_output><jupyter_text>Get article from Scihub<jupyter_code>sh = SciHub()
def scihub_download(doi, save="text2.pdf"):
    try:
        dl = sh.download(doi)
    except Exception as e:
        print(e)
        return False
#     with open(save, 'wb') as output:
#         output.write(dl['pdf'])
    return True
scihub_download(doi)<jupyter_output><empty_output><jupyter_text>Get citations from Crossref<jupyter_code>cr = Crossref()
print(cn.content_negotiation(ids=doi, format="bibentry"))
# cn.content_negotiation(ids = '10.1126/science.169.3946.635')
# cn.content_negotiation(ids = '10.1126/science.169.3946.635', format = "citeproc-json")
# cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "rdf-xml")
# cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "text")
# cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "text", style = "apa")
# cn.content_negotiation(ids = "10.1126/science.169.3946.635", format = "bibentry")
x = cr.works(query = "consciousness author:dennett", offset=0)
x['status']
x['message']['items'][0]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.04298082869511441, 'mean_word_length': 4.766488413547237, 'pattern_counts': {'":': 1, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '198872', 'license': 'MIT', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1166, 'n_words': 172, 'path': 'Ugarit API.ipynb', 'repo_name': 'machaerus/ugarit', 'size': '3252'}