INNER CODE UNIT · Python

get_lastmod

netkiller/netkiller.github.io · generate_sitemaps.py:23

def get_lastmod(filepath):
    """Get last modification date of a file."""
    mtime = os.path.getmtime(filepath)
    return datetime.fromtimestamp(mtime).strftime('%Y-%m-%d')

def url_encode_path(path):
    """URL encode a file path."""
    parts = str(path).split('/')
    encoded_parts = [quote(part, safe='') for part in parts]
    return '/'.join(encoded_parts)

def extract_title(filepath):
    """Extract title from HTML file."""
    try:
        with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
            content = f.read(5000)  # Read first 5KB
            match = re.search(r'<title>(.*?)</title>', content, re.IGNORECASE | re.DOTALL)
            if match:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…