Skip to content

Instantly share code, notes, and snippets.

View Adoria298's full-sized avatar

Adoria298

View GitHub Profile
@Adoria298
Adoria298 / comment2bibtex.py
Last active September 19, 2021 10:55
comment2bibtex - turns a URL in a Python comment into a BibTeX reference.
import requests # pip install requests
import bs4 # pip install beautifulsoup4
from pathlib import Path # part of the python 3.6+ standard library
in_file = Path(__file__).parent / input("Relative path to file: ")
comments = []
def is_url(word):
if ("http" in word or "www" in word): # most URLS have at least one of the two
return True
with open(in_file) as fp: