scholrly / dblp-python

A simple Python wrapper around the DBLP API, currently supporting author search and author and publication lookup.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Searching for author with a running number

mrksbrg opened this issue · comments

Some authors share the same name and thus a number is appended to their DBLP profile, e.g., "Thomas Olsson 0001" for https://dblp.uni-trier.de/pers/hd/o/Olsson_0001:Thomas

As far as I understand, the wrapper does not work for such names.

I'd love to see a solution to this issue!

Do the following changes in the init.py file:

def search(author_str): resp = requests.get(DBLP_AUTHOR_SEARCH_URL, params={'xauthor':author_str}) #TODO error handling root = etree.fromstring(resp.content) arr_of_authors = [] for urlpt in root.xpath('/authors/author/@urlpt'): resp1 = requests.get(DBLP_PERSON_URL.format(urlpt=urlpt)) xml = resp1.content root1 = etree.fromstring(xml) if root1.xpath('/dblpperson/homonym/text()'): for hom_urlpt in root1.xpath('/dblpperson/homonym/text()'): arr_of_authors.append(Author(hom_urlpt)) else: arr_of_authors.append(Author(urlpt)) return arr_of_authors

I tried to write the code indented here in this comment, but I don't know why it won't happen.
I hope you will be able to understand.
Though this method kills the purpose of loading data lazily, but it still solves the issue.

Hi, thanks for looking into this! It works for me, and I believe this will be good enough for my purpose.