# -*- coding: utf-8 -*-
"""校验 index.html 合规性"""
import re, sys
html = open('index.html', encoding='utf-8').read()
PRODUCT_IMGS = [
"Image260914185828073177.jpg",
"Image260914185825479878.jpg",
"Image2609141858254798df.jpg",
"Image260914185827307941.jpg",
"Image2609141858286671fe.jpg",
"Image2609141858264178bf.jpg",
"Image260914185828010d52.jpg",
"Image260914185827120258.jpg",
]
BANNER = "Image260916111139706c0d.png"
ABOUT = "Image260916110252046a67.png"
CITY_LINKS = [
"https://uyogr.qianyin168.com","https://mcueh.szbla.com","https://bqdwm.773588.com",
"https://vvwzv.xmotp.com","https://pwniv.yuanyince1688.com","https://zyint.zhfmgc.com",
"https://vygwe.jntfw.com","https://eiarf.bfcmgg.com","https://unmtj.qianyin168.com",
"https://plonb.buhuihua.com",
]
FRIEND_LINKS = [
"https://qcbsf.51mplg.com","https://pzvza.yuanyince1688.com","https://sludj.layouwei.com",
"https://cemtf.51mplg.com","https://nunlz.jntfw.com","https://qbkhi.hgesf.com",
"https://dccof.wggjl.com","https://ctqre.yu68999.com","https://ypslk.buhuihua.com",
"https://zyscx.836188.com",
]
errors = []
warns = []
# 1. 图片检查:是否只用指定链接,无额外图片
used_imgs = re.findall(r'https?://cdn\.qiancipai\.com/([^\s"\'<>]+)', html)
allowed = set(PRODUCT_IMGS + [BANNER, ABOUT])
for u in used_imgs:
if u not in allowed:
errors.append(f"使用了未授权的图片: {u}")
# 确认所有指定图片都被用到(可选,至少检查关键)
for a in allowed:
if a not in html:
warns.append(f"指定图片未使用: {a}")
# 2. form / input 检查(禁止用户输入模块)
if re.search(r'<(form|input|textarea)\b', html, re.I):
errors.append("页面包含 form/input/textarea,违反无用户输入模块约束")
# 3. 三要素
for tag in ['title', 'keywords', 'description']:
if f'name="{tag}"' not in html and f'<{tag}' not in html:
errors.append(f"缺少 {tag}")
if '安徽亳州' not in html:
warns.append("三要素/内容未体现安徽亳州地区")
# 4. 资质证书板块检查:规则说没提供则不写 -> 确认无资质证书板块
if '资质' in html or '证书' in html:
warns.append("页面出现资质/证书内容,素材未提供,建议移除")
# 5. ICP 备案检查
if 'ICP' in html or 'icp' in html or '备案号' in html:
errors.append("底部出现 ICP 备案信息,违反约束")
# 6. Banner 比例检查
if 'aspect-ratio: 1920 / 1000' not in html:
errors.append("Banner 未设置 1920:1000 比例")
if BANNER not in html:
errors.append("Banner 图未使用指定链接")
if ABOUT not in html:
errors.append("关于我们配图未使用指定链接")
# 7. 板块完整性
for sec, kw in [
('首页Banner', 'banner'), ('产品展示', 'products'), ('关于我们', 'about'),
('应用场景', 'scenarios'), ('合作案例', 'cases'), ('售后服务', 'service'),
('FAQ', 'faq'), ('城市分站', 'cities'), ('友情链接', 'links'),
]:
if f'id="{kw}"' not in html:
errors.append(f"缺少板块: {sec}")
# 8. 分站链接齐全
for c in CITY_LINKS:
if c not in html:
errors.append(f"缺少城市分站: {c}")
if len(CITY_LINKS) != 10:
errors.append("城市分站数量非10个")
for f in FRIEND_LINKS:
if f not in html:
errors.append(f"缺少友情链接: {f}")
if len(FRIEND_LINKS) != 10:
errors.append("友情链接数量非10个")
# 9. 绝对化用语检查(广告法)
banned = ['最', '第一', '顶级', '全网最优', '最好', '唯一', '国家级', '极致']
for b in banned:
# 在中文语境下检查(忽略代码/注释)
text_part = re.sub(r'<[^>]+>', '', html)
if b in text_part:
warns.append(f"文案可能含绝对化用语: 「{b}」")
print("=== 错误 (必须修复) ===")
for e in errors: print(" ✗", e)
print("\n=== 警告 (建议确认) ===")
for w in warns: print(" !", w)
print("\n=== 用到的图片清单 ===")
for u in used_imgs: print(" ✓", u)
print("\n图片叠加文字检查:搜索 banner-overlay 文字...")
overlay_text = re.findall(r'class="banner-overlay">(.*?)', html, re.S)
if overlay_text:
print(" Banner 叠加内容:", overlay_text[0].strip()[:100])
else:
print(" ✓ Banner 无文字叠加(仅 img)")
sys.exit(1 if errors else 0)