Assorted shell and Python scripts
at main 32 lines 710 B view raw
1#!/usr/bin/env -S uv run --script 2# /// script 3# dependencies = [ 4# "beautifulsoup4", 5# "requests", 6# ] 7# /// 8 9import sys 10 11import requests 12from bs4 import BeautifulSoup 13 14 15def main(): 16 if len(sys.argv) != 2: 17 exit("Usage: print-wp-sources ARTICLE_URL") 18 article_url = sys.argv[1] 19 20 text = requests.get(article_url).text 21 soup = BeautifulSoup(text, "html.parser") 22 for link in soup.find_all("a", attrs={"class": "external text"}): 23 if "wikimediafoundation.org" not in link.get( 24 "href" 25 ) and "foundation.wikimedia.org" not in link.get("href"): 26 print(link.get("href")) 27 28 29if __name__ == "__main__": 30 main() 31 32# vim: ai et ft=python sts=4 sw=4 ts=4