ckreibich / scholar.py

A parser for Google Scholar, written in Python
2.11k stars 777 forks source link

Possible to print BibTex citation within Python? #50

Open laucl opened 9 years ago

laucl commented 9 years ago

Can you provide an example python script where you print the BibTex Citation?

wasified commented 9 years ago

You need to get citation_data from a query instance.

You could try something like this:

import scholar

querier = scholar.ScholarQuerier()
settings = scholar.ScholarSettings()
settings.set_citation_format(4) #4 is for BibTex
querier.apply_settings(settings)

#Take in search phrase and return BibTex of first article found
def searchScholarsearchphrase):
    query = scholar.SearchScholarQuery()
    query.set_words(searchphrase)
    querier.send_query(query)
    return querier.articles[0].citation_data

searchScholar('Your phrase here')
skyl commented 8 years ago

print(article.as_citation())?