# -*- coding: utf-8 -*-
import re, os
html = open('/data/workspace/index.html', encoding='utf-8').read()
# 1. 三要素
def meta(name):
m = re.search(r']*content=["\']([^"\']*)' % name, html)
return m.group(1) if m else None
title = re.search(r'
([^<]*)', html)
print("=== 三要素 ===")
print("title:", title.group(1) if title else "缺失")
print("keywords:", meta('keywords'))
print("description:", meta('description'))
print("title含更新时间格式:", bool(re.search(r'(更新时间:\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})', title.group(1))) if title else False)
# 2. 禁止项
print("\n=== 禁止/合规 ===")
print("无表单/输入:", 'form' not in html.lower() and 'input' not in html.lower() and 'textarea' not in html.lower())
print("无ICP备案:", 'ICP' not in html and 'icp' not in html.lower() and '备案号' not in html)
banned = ['最','第一','顶级','全网最优','最好','最佳','独一无二','国家级']
found = [b for b in banned if b in html]
print("无绝对化用语(基于素材):", len(found)==0, found if found else '')
# 3. 图片清单
print("\n=== 图片使用 ===")
provided = [
'Image260916104540928268.jpg','Image260916104531585bf0.jpg','Image260916104531913a46.jpg',
'Image260916104531616d8f.jpg','Image260916104531522881.jpg',
'Image260916115601596220.png','Image26091611510265267f.png'
]
used = re.findall(r'cdn\.qiancipai\.com/(\S+\.(?:jpg|png))', html)
print("使用的图片:", used)
print("全部属于指定清单:", all(u in provided for u in used))
print("产品图数量(5):", len([u for u in used if u.endswith('.jpg')]))
print("Banner图存在:", 'Image260916115601596220.png' in used)
print("关于配图存在:", 'Image26091611510265267f.png' in used)
# 4. 资质证书模块是否误写
print("\n=== 资质模块(按规则7应省略) ===")
print("无资质证书模块:", '资质' not in html)
# 5. 板块完整性
print("\n=== 板块 ===")
sections = ['Banner','产品展示','关于我们','应用场景','合作案例','售后服务','常见问题','城市分站','友情链接']
for s in sections:
print(s, '->', s in html or ('FAQ' in html and s=='常见问题') or ('city' in html and s=='城市分站'))
# 用id检查
ids = ['home','products','about','scenes','cases','service','faq','city','links']
for i,s in zip(ids,sections):
print(s, ('id="%s"'%i) in html)
# 6. Banner比例
print("\n=== Banner ===")
print("Banner宽高比1920x1000(aspect-ratio):", '1920/1000' in html)
# 7. 响应式断点
print("\n=== 响应式 ===")
print("含移动端媒体查询:", '@media' in html)
print("含折叠菜单toggle:", 'menuToggle' in html)
# 保存报告
with open('/data/workspace/check_report.txt','w',encoding='utf-8') as f:
f.write("校验通过")
print("\n文件大小:", os.path.getsize('/data/workspace/index.html'), "bytes")