pip install mwrefs
This library provides a set of utilities for extracting references and reference identifiers from wikitext.