scholarly
scholarly copied to clipboard
Can the search_... functions return a count of the results?
What feature would you like to request? I would find it really helpful if I could programmatically get the number of Google Scholar results on a subject, given a keyword.
Is your feature request related to a problem? Please describe. I am working on an inventory management project where I have to find the number of academic publications on a given item. The specific titles, authors, institutions are not immediately relevant. I came across scholarly, and it offers a very nice keyword search function, but it returns a generator of author objects with no option to just get the number of hits.
Describe the solution you'd like
Ideally, I would like to be able to run something like n_hits= scholarly.search_keyword('Haptics', num_authors=True)
, and have n_hits
be an int corresponding to the number of authors in the generator.
Describe alternatives you've considered
Another good implementation would be something like:
search_query = scholarly.search_keyword('Haptics') print(search_query.n_results)
Do you plan on contributing? Your response below will clarify if this is something that the maintainers can expect you to work on or not.
- [x] Yes, I plan to contribute towards this feature in the next couple of days.
Additional context In _navigator.py, there is a logger that keeps track of number of authors found, and when author pages end. If it could return this info somehow, that would be great too.
Some search_
functions already return this that are accessbile via the total_results
attribute. I don't remember off the top of my head if search_keyboard
returns this or not. See here for examples: https://github.com/scholarly-python-package/scholarly/blob/9269ff36ad2314e6cc0c5b499efc3b79b844707e/test_module.py#L735-L750
I just tested it out, and search_keyword does not have total_results implemented. I think it's because search_keyword does not return a SearchScholarIterator, unlike search_pubs.
Based on the WIEN2k Blaha example, it looks like search_pubs will get all publications that have the search term in their title, not just exact matches, right? For now, I will use that as a substitute for search_keyword(...).total_results in my project. Thanks for pointing those tests out.