| 12345678910111213141516171819202122232425262728293031 |
- import re, os
- wiki_dir = "C:\\Coding\\python\\dropbox-pictures-regex\\wiki\\"
- # koment
- regex = r"(?:(?:https?)+\:\/\/+[a-zA-Z0-9\/\._-]{1,})+(?:(?:jpe?g|png))"
- for path, dirs, files in os.walk(wiki_dir):
- for file in files:
- if file.endswith('.md'):
- file_path = os.path.join(path, file)
- with open(file_path, 'r', encoding='utf8') as f:
- text = f.read()
- matches = re.findall(regex, text)
- for match in matches:
- print(f"Soubor: {file_path}\nobrazek: {match}")
- # match.split("/")[-1]
- # posledni vec za lomitkem
- # import requests
- #
- # match
- # 'https://paper-attachments.dropboxusercontent.com/s_24178BD4A5DAB9E5982E958D5E436EA3EE292ED76CE0CE756BCC4AC8A6171443_1711543972132_image.png'
- # resp = requests.get(match)
- # match.split("/")[-1]
- # 's_24178BD4A5DAB9E5982E958D5E436EA3EE292ED76CE0CE756BCC4AC8A6171443_1711543972132_image.png'
- # with open(match.split("/")[-1], "wb") as fp:
- # fp.write(resp.content)
|