Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted to Python 3, and added a function #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,50 @@ Let's search for `Michael Ley`_, DBLP maintainer. Try ::
>>> #do a simple author search for michael ley
>>> authors = dblp.search('michael ley')
>>> michael = authors[0]
>>> print michael.name
>>> print(michael.name)
Michael Ley
>>> print len(michael.publications)
>>> print(len(michael.publications))
31

If you'd like to learn more about Michael's work, you can explore his publications. All publication results are lazy-loaded, so have at it ::

>>> print michael.publications[0].title
>>> print(michael.publications[0].title)
DBLP - Some Lessons Learned.
>>> print michael.publications[0].journal
>>> print(michael.publications[0].journal)
PVLDB
>>> print michael.publications[0].year
>>> print(michael.publications[0].year)
2009

More information about a publication can often be found at its `ee` URL - in this case, a link to the PDF ::

>>> print michael.publications[0].ee
>>> print(michael.publications[0].ee)
http://www.vldb.org/pvldb/2/vldb09-98.pdf

Other publication and author attributes are documented with their respective classes- just use `help()`. Enjoy!

.. _Michael Ley: http://www.informatik.uni-trier.de/~ley/


If you'd like to learn more about Michael's work, you can explore his publications. All publication results are lazy-loaded, so have at it ::

>>> print michael.publications[0].title
DBLP - Some Lessons Learned.
>>> print michael.publications[0].journal
PVLDB


Keyword search ::

>>> import dblp
>>> papers = dblp.publ_search('Protein Function Prediction')
>>> papers[0].authors
['Pingping Sun', 'Xian Tan', 'Sijia Guo', 'Jingbo Zhang', 'Bojian Sun', 'Ning Du', 'Han Wang', 'Hui Sun']
>>> papers[0].title
'Protein Function Prediction Using Function Associations in Protein-Protein Interaction Network.'
>>> papers[0].mdate
'2020-10-26'


Contributing
============

Expand Down
13 changes: 12 additions & 1 deletion dblp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

DBLP_BASE_URL = 'http://dblp.uni-trier.de/'
DBLP_AUTHOR_SEARCH_URL = DBLP_BASE_URL + 'search/author'
DBLP_PUB_SEARCH_URL = DBLP_BASE_URL + 'search/publ/api'

DBLP_PERSON_URL = DBLP_BASE_URL + 'pers/xk/{urlpt}'
DBLP_PUBLICATION_URL = DBLP_BASE_URL + 'rec/bibtex/{key}.xml'
Expand All @@ -18,7 +19,7 @@ def __getattr__(self, key):
if self.data is None:
self.load_data()
return self.data[key]
raise AttributeError, key
raise AttributeError(key)

def load_data(self):
pass
Expand Down Expand Up @@ -140,6 +141,16 @@ def load_data(self):

self.data = data

def publ_search(publ_str):
# Iddo Friedberg: search using keywords in publications. Return all publicaitons with these keywords
publications = []
resp = requests.get(DBLP_PUB_SEARCH_URL, params={'q':publ_str})
root = etree.fromstring(resp.content)
for des in root.iterdescendants():
if des.tag == "key":
publications.append(Publication(des.text))
return publications

def search(author_str):
resp = requests.get(DBLP_AUTHOR_SEARCH_URL, params={'xauthor':author_str})
#TODO error handling
Expand Down