mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-10 20:28:28 +03:00
20 lines
383 B
Python
20 lines
383 B
Python
|
|
import os, requests
|
|
from loguru import logger
|
|
|
|
|
|
def mkdir_if_not_exists(folder):
|
|
if not os.path.exists(folder):
|
|
os.mkdir(folder)
|
|
|
|
|
|
def expand_url(url):
|
|
# expand short URL links
|
|
if 'https://t.co/' in url:
|
|
try:
|
|
r = requests.get(url)
|
|
url = r.url
|
|
except:
|
|
logger.error(f'Failed to expand url {url}')
|
|
return url
|