[Tex/LaTex] How to automatically create a .bib file for the references of a paper

articlebibliographiesbibtexmendeley

I have a published paper and I am going to use it in my dissertation. I normally use Mendeley to create .bib file. However, I am wondering is there a smart and easy way to create this .bib file by just providing the paper or doi of the paper and it gives me the .bib file of the references?

For example, I want a .bib file that contains the references of this article:
https://www.cambridge.org/core/journals/microscopy-and-microanalysis/article/estimating-step-heights-from-topdown-sem-images/ECA77A258DAA20A73CA510AADFFD4F08

Best Answer

It's not TeX, but I use this python 3 code to do something like this:

from isbnlib import meta
from isbnlib.registry import bibformatters
import sys
import urllib.request
from urllib.error import HTTPError
import time

### PARA DOI
#BASE_URL = 'http://dx.doi.org/'
BASE_URL = 'https://www.doi.org/'

ListaDOI = ['10.1119/1.5124814',
            '10.1103/PhysRevB.100.245121',
            '10.1103/PhysRevB.100.224507',
            '10.1103/PhysRevE.100.052303',
            '10.1103/PhysRevFluids.4.124002',
            '10.1103/PhysRevD.100.126011',
            '10.1103/PhysRevA.100.052322']

### PARA ISBN
SERVICE = 'openl'
getInfoISBN = bibformatters['bibtex']

ListaISBN = []


#timestamp=time.strftime("%d-%m-%Y-%H%M%S")
timestamp=time.strftime("%d-%m-%Y-%H")
filename='bibliography-'+timestamp+'.txt'
g=open(filename,'a')

for doi in ListaDOI:
    url = BASE_URL + doi
    req = urllib.request.Request(url)
    req.add_header('Accept', 'application/x-bibtex')
    time.sleep(2)
    try:
        with urllib.request.urlopen(req) as f:
            bibtexDOI = f.read().decode()
        print(bibtexDOI)
        g.write('\n' + bibtexDOI + '\n\n')

    except HTTPError as e:
        if e.code == 404:
            print('\n DOI {} nao encontrado. DOI not found.\n'.format(doi))
            g.write('DOI: {}'.format(doi)+' não encontrado. Not found.\n\n')
        else:
            print('Serviço indisponível. Service unavailable.')
            sys.exit(1)

for isbn in ListaISBN:
    try:
        bibtexISBN = getInfoISBN(meta(isbn, SERVICE))
        print(bibtexISBN)
        g.write('\n' + bibtexISBN + '\n\n')

    except:
        print('\n ISBN {} nao encontrado. ISBN not found.\n'.format(isbn))
        g.write('ISBN: {}'.format(isbn)+' não encontrado. Not found.\n\n')
g.close()

It uses the site http://dx.doi.org/ to get the information. So, you list the doi number in 'ListaDOI' (how many you need) and just run with your python. It will show the bib entry and save it into a 'bibliography.txt'.

Edit: added isbn search. It uses a specific python lib, the isbnlib. The same way you put isbn into 'ListaISBN', like in 'ListaDOI'.

Related Question