Created
October 14, 2023 18:38
-
-
Save fogti/a480be939ff3239e22afa5dc83b91007 to your computer and use it in GitHub Desktop.
fefe, but only the links (without the comments)
This file contains 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
#!/usr/bin/env python3 | |
import html.parser | |
import requests | |
known = ["/", "/faq.html", "//alternativlos.org/", "impressum.html"] | |
class OnlyLinks(html.parser.HTMLParser): | |
def handle_starttag(self, tag, attrs): | |
if tag == 'li': | |
print('---') | |
elif tag == 'a': | |
try: | |
href = [v for k, v in attrs if k == 'href'][0] | |
if 'fefe.de/' not in href and not href.startswith('?ts=') and not href.startswith('/?mon=') and not href in known: | |
print(href) | |
except ValueError: | |
pass | |
dat = requests.get('https://blog.fefe.de', stream = True).iter_lines(decode_unicode = True) | |
stm = OnlyLinks() | |
for i in dat: stm.feed(i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment