davidagraf / doi2bib

give us a DOI and we'll do our best to get you the BibTeX entry
www.doi2bib.org
118 stars 15 forks source link

Query of you webApp with python BeautifulSoup #14

Closed jvtrudel closed 9 years ago

jvtrudel commented 9 years ago

Thanks for this wonderful tool, I cannot figure out why it did not exist since many years.

I'd like to retrieve bibtex entries using a python script that query your web app doi2bib.org. The idea is to be able to automate the construction of bibtex database files from a list of doi.

Here is my first try :

from urllib2 import urlopen 
import bs4 as BeautifulSoup 
doi="10.1103/PhysRevLett.103.123005"
resolver="http://www.doi2bib.org/#/"
html = urlopen(resolver+doi+"?doi2bib").read() # http request
soup = BeautifulSoup.BeautifulSoup(html,"lxml")   # html parsing
print soup.prettify()     # see what I get ...

Unfortunately, I cannot see the box objet that contain the result. I suspect that the issue is related with the way javascript transfert information to the browser, but I am not a web programmer and I'm totally lost.

Do you have an idea of what might be the problem? Do you you think it is an issue or is it due to my lack of knowledge of web technology?

Also, would you be interested to include python and (maybe) lua scripts in doi2bib? For example, it could used to quickly fetch bibtex entries within luaLatex.

thurnherr commented 9 years ago

It's great to hear you are using our tool!

My suggestion would be to send your queries directly to http://dx.doi.org. You can find several (more or less sophisticated) scripts online. See here for an example in Python.

Querying bibtex entries from within LuaLaTeX would certainly be convenient. However, I'm not familiar with Lua and would have to look into it...

jvtrudel commented 9 years ago

Great, thx. So simple!