Skip to content

Instantly share code, notes, and snippets.

@russelljjarvis
Last active December 7, 2018 19:26
Show Gist options
  • Save russelljjarvis/9ffc4339b4ded694c9d76f1688b111f9 to your computer and use it in GitHub Desktop.
Save russelljjarvis/9ffc4339b4ded694c9d76f1688b111f9 to your computer and use it in GitHub Desktop.
#!pip install -e +git https://github.com/ckreibich/scholar.py
import sys
from scholar_scrape import scholar
import pandas as pd
unicode = str # pylint: disable-msg=W0622
encode = lambda s: unicode(s) # pylint: disable-msg=C0103 '''
def csv(querier, header=False, sep='|'):
articles = querier.articles
results = []
for art in articles:
result = art.as_csv(header=header, sep=sep)
results.append(result)
print(encode(result))
header = False
return results
def citation_export(querier):
articles = querier.articles
for art in articles:
print(art.as_citation() + '\n')
return articles
def search_author(author):
# from https://github.com/ckreibich/scholar.py/issues/80
querier = scholar.ScholarQuerier()
settings = scholar.ScholarSettings()
querier.apply_settings(settings)
query = scholar.SearchScholarQuery()
query.set_words(str('author:')+author)
querier.send_query(query)
results0 = csv(querier)
results1 = citation_export(querier)
links = [ a.attrs['url'][0] for a in querier.articles if a.attrs['url'][0] is not None ]
return results0, results1, links
links, results0, _ = search_author('R Gerkin')
print(links, results0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment