引数で渡ってきたファイルを読み込んでテキストからURLを抽出する関数。
URLって正規表現で取れるんだって思った。htmlなりmarkdownなりtextなりをfindでpythonに渡しつつ実行すれば中のURLだけを抽出して出力することが可能なプログラムが書ける。以下のようなテキストで有効なurlを抽出させることができる。
https://www.google.com <src=https://www.google.com></src=https://www.google.com> aaaa: https://www.google.com :bbbb hts://www.google.com\\\ ___https://www.google.com:9090/aaa?aaa https://www.\google.\com
実行。listをprintしてるからこんな感じだがきちんと出力させればパイプでつなげることで色々と使える幅は広いはず。
['https://www.google.com', 'https://www.google.com', 'https://www.google.com', 'https://www.google.com', 'https://www.google.com:9090/aaa?aaa']