Skip to content

Instantly share code, notes, and snippets.

@smarr
Last active May 13, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarr/9093f82f09572a66b561534333f3db42 to your computer and use it in GitHub Desktop.
Save smarr/9093f82f09572a66b561534333f3db42 to your computer and use it in GitHub Desktop.
Download missing bib entries from Bibsonomy
#!/usr/bin/python3
import re
import requests
bibkey_re = re.compile("Warning--I didn't find a database entry for \"(.*?)\"")
with open("paper.blg") as f:
content = f.readlines()
for line in content:
m = bibkey_re.match(line)
if m:
print("Download: https://www.bibsonomy.org/bib/bibtexkey/" + m.group(1) + "/gron")
bibentry = requests.get("https://www.bibsonomy.org/bib/bibtexkey/" + m.group(1) + "/gron")
with open("bibsonomy.bib", "a") as bib_file:
bib_file.write(bibentry.content + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment