import xml.etree.ElementTree as ET
import re

file_path = "/home/user/uploads/thediscinitiatives.WordPress.2025-08-09.xml"
namespaces = {'wp': 'http://wordpress.org/export/1.2/', 'content': 'http://purl.org/rss/1.0/modules/content/'}

tree = ET.parse(file_path)
root = tree.getroot()

for item in root.findall('.//item'):
    post_type = item.find('wp:post_type', namespaces)
    pt = post_type.text if post_type is not None else 'unknown'
    
    if pt in ['page', 'post', 'team']:
        title = item.find('title').text
        content = item.find('content:encoded', namespaces)
        content_text = content.text if content is not None and content.text else ""
        
        # Check for suspicious links
        urls = re.findall(r'href=[\'"]?(https?://[^\'" >]+)', content_text)
        suspicious = [url for url in urls if 'discinitiatives.org' not in url and 'elementor' not in url and 'wordpress' not in url]
        
        if suspicious:
            print(f"Type: {pt} | Title: {title}")
            print(f"Suspicious links: {suspicious[:3]}...")
            
