Created
May 23, 2019 05:26
-
-
Save joshbrooks/496fdecc78688ccf6e76bb3a7b835eed to your computer and use it in GitHub Desktop.
List all Superset charts for iframe inclusion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # parser.py | |
| # Requires "beautifulsoup4", pip install it | |
| from bs4 import BeautifulSoup | |
| import urllib.request | |
| class SupersetRefPuller: | |
| def __init__(self, url="https://superset-myeqip.catalpa.build/chart/list/"): | |
| self.url = url | |
| def pull_chart_list(self): | |
| with urllib.request.urlopen(self.url) as response: | |
| html = response.read() | |
| soup = BeautifulSoup(html) | |
| all_links = soup("a") | |
| return all_links | |
| def filter_chart_links(self): | |
| return [ | |
| (l.text.strip(), l["href"]) | |
| for l in self.pull_chart_list() | |
| if "slice_id" in l["href"] | |
| ] | |
| if __name__ == "__main__": | |
| page = SupersetRefPuller() | |
| links = page.filter_chart_links() | |
| for link in links: | |
| print(link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment