You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm using the example code to try and figure out how to get to the "bib" keys I need.
This is what I've modified so far.
from scholarly import scholarly
search_query = scholarly.search_author('Steven A Cholewiak')
author = scholarly.fill(next(search_query))
for pub in author['publications']:
if (pub['bib']['pub_year']) == '2021':
print(pub['bib']['pub_year'],pub['bib']['title'],pub['bib']['citation'])
I was trying to figure out a way of limiting the results to a year (this throws an error "KeyError: 'pub_year'"). Even with the error it produces output but this particular query on the Google Scholar form retrieves one record while my code gets two results.
I'm also trying to get author and publisher but those don't work as keys with the code above. Do I need to fill publications? I was surprised to find citation worked.
I'm new to Python so apologies for the noob coding.
Thanks!
Figured it out - adding a fill above my if statement got me the data I was looking for:
for pub in author['publications']:
if (pub['bib']['pub_year']) == '2021':
scholarly.fill(pub)
print(pub['bib']['author'],pub['bib']['title'],pub['bib']['citation'])
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm using the example code to try and figure out how to get to the "bib" keys I need.
This is what I've modified so far.
I was trying to figure out a way of limiting the results to a year (this throws an error "KeyError: 'pub_year'"). Even with the error it produces output but this particular query on the Google Scholar form retrieves one record while my code gets two results.
I'm also trying to get author and publisher but those don't work as keys with the code above. Do I need to fill publications? I was surprised to find citation worked.
I'm new to Python so apologies for the noob coding.
Thanks!
Figured it out - adding a fill above my if statement got me the data I was looking for:
Beta Was this translation helpful? Give feedback.
All reactions