ckreibich / scholar.py

A parser for Google Scholar, written in Python
2.12k stars 776 forks source link

How to use from within Python for "searching with author/word/phrase" #80

Open sreejithmangattil opened 7 years ago

sreejithmangattil commented 7 years ago

Which is the proper way to use code from within Python(instead of command line)? I tried with the following line of code, but its giving me an empty array.

import scholar querier = scholar.ScholarQuerier() settings = scholar.ScholarSettings() querier.apply_settings(settings)

def searchScholar(searchphrase): query = scholar.SearchScholarQuery() query.set_words(searchphrase) querier.send_query(query) print(len(querier.articles))

searchScholar('Evaluating technologies for education')

devinhiggins commented 7 years ago

Same issue for me!

LVZxZa commented 7 years ago

Yo, I think this is the fix you're looking for. It took me ages to figure this out, and this is the first time I've ever written any code that someone else might use, so I'd be pretty chuffed if it helps.

import scholar querier = scholar.ScholarQuerier() settings = scholar.ScholarSettings() querier.apply_settings(settings) query = scholar.SearchScholarQuery()

def searchScholar(searchphrase): query.set_words(searchphrase) query.get_url() querier.send_query(query) print scholar.csv(querier)

searchScholar('Evaluating technologies for education')

max-quirk commented 6 years ago

What does this code have to do with scholar.py? Is it supposed to be inserted in it, or an entirely separate file?

LVZxZa commented 6 years ago

This is for use in a seperate file in order to script scholar.py activity in other projects.

On 27 Nov 2017, at 01:52, Max Quirk notifications@github.com wrote:

What does this code have to do with scholar.py? Is it supposed to be inserted in it, or an entirely separate file?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.