完成wordpress到django站点的数据迁移,下一届阶段完成前端样式的轻度编写

This commit is contained in:
2026-10-20 02:55:22 +08:00
parent 9592e6a150
commit 16a75807ee
30 changed files with 27989 additions and 51 deletions
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env python
import os
import sys
import django
import re
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blogsite.settings')
django.setup()
from blog.models import Post
OLD_DOMAINS = ['an.xiaoan.xyz', 'xiaoan.xyz']
print("=" * 60)
print("排查残留的图片 URL")
print("=" * 60)
for domain in OLD_DOMAINS:
print(f"\n--- 搜索域名: {domain} ---\n")
# 正文里残留的
posts = Post.objects.filter(content__contains=domain)
for post in posts:
# 用正则把所有包含该域名的 src/href/url 提取出来
matches = re.findall(r'https?://' + re.escape(domain) + r'[^"\')\s]+', post.content)
if matches:
print(f" 文章: {post.title}")
for m in set(matches): # set 去重
print(f" {m}")
print()
# 摘要里残留的
posts = Post.objects.filter(excerpt__contains=domain)
for post in posts:
if not post.excerpt:
continue
matches = re.findall(r'https?://' + re.escape(domain) + r'[^"\')\s]+', post.excerpt)
if matches:
print(f" 摘要: {post.title}")
for m in set(matches):
print(f" {m}")
print()
print("=" * 60)
print("排查完成")