#!/usr/bin/env python3 # -*- coding: utf-8 -*- """自检脚本:验证 index.html 对硬性约束的合规情况""" import re with open("index.html", "r", encoding="utf-8") as f: html = f.read() banner = "http://cdn.qiancipai.com/Image260916150037846614.png" about = "http://cdn.qiancipai.com/Image26091614584183361d.png" product_imgs = [ "http://cdn.qiancipai.com/Image2609141911140562b6.jpg", "http://cdn.qiancipai.com/Image260914191115993315.jpg", "http://cdn.qiancipai.com/Image260914191113368ddf.jpg", "http://cdn.qiancipai.com/Image2609141911151655ed.jpg", "http://cdn.qiancipai.com/Image260914191115290ce8.jpg", "http://cdn.qiancipai.com/Image2609141911147744c1.jpg", "http://cdn.qiancipai.com/Image260914191115571fee.jpg", "http://cdn.qiancipai.com/Image26091419111430694a.jpg", ] def count(tag): return html.count(tag) print("=" * 60) print("自检报告") print("=" * 60) checks = [] # 1. 无用户输入模块 has_form = bool(re.search(r"(.*?)", html, re.S) keywords = re.search(r'name="keywords" content="([^"]+)"', html) desc = re.search(r'name="description" content="([^"]+)"', html) c2 = bool(title and keywords and desc and title.group(1).strip() and keywords.group(1).strip() and desc.group(1).strip()) checks.append(("② title/keywords/description 三要素非空", c2, f"title={'有' if title and title.group(1).strip() else '空'} keyword={'有' if keywords and keywords.group(1).strip() else '空'} desc={'有' if desc and desc.group(1).strip() else '空'}")) if title: print(" title:", title.group(1)[:60], "...") if keywords: print(" keywords:", keywords.group(1)[:60], "...") if desc: print(" description:", desc.group(1)[:60], "...") # 3. Banner 完整显示 + 比例 c3 = (banner in html) and ("1920 / 1000" in html or "1920/1000" in html) and ("aspect-ratio" in html) checks.append(("③ Banner 使用指定图 + 1920x1000 比例完整显示", c3, f"banner引用={'有' if banner in html else '无'}, aspect-ratio={'有' if '1920 / 1000' in html else '无'}")) # 4. 关于我们配图 c4 = about in html checks.append(("④ 关于我们配图使用指定图", c4, f"about图引用={'有' if c4 else '无'}")) # 5. 产品图片:8张全部使用,且检查是否有 img 上叠加文字(此处仅确认8张都在) used = [img for img in product_imgs if img in html] c5 = len(used) == 8 checks.append(("⑤ 8张产品图片全部使用", c5, f"已引用 {len(used)}/8")) # 6. 绝对化用语检查(广告法) banned = ["最", "第一", "顶级", "全网最优", "最好", "唯一", "极致", "史上"] found_banned = [w for w in banned if w in html] c6 = len(found_banned) == 0 checks.append(("⑥ 无广告法绝对化用语", c6, f"命中={found_banned if found_banned else '无'}")) # 7. 资质证书板块(素材未提供资质图/文字 -> 不应有此板块) has_qual = ("资质" in html) c7 = not has_qual checks.append(("⑦ 无资质证书板块(素材未提供)", c7, f"含'资质'={'有' if has_qual else '无'}")) # 8. 无 ICP 备案 has_icp = bool(re.search(r"ICP|备案号|beian", html, re.I)) c8 = not has_icp checks.append(("⑧ 底部无ICP备案信息", c8, f"含ICP={'有' if has_icp else '无'}")) # 9. 城市分站:10个链接齐全 city_urls = [ "adqge.qianyin168.com","iwsfn.yuanyince1688.com","zqsqc.xmotp.com", "fkwke.zhfmgc.com","pfghk.tbtnt.com","ftfxu.jntfw.com", "ohzmc.szbla.com","qzpeo.xmotp.com","klmuq.836188.com","favys.51mplg.com", ] city_ok = sum(1 for u in city_urls if u in html) c9 = city_ok == 10 checks.append(("⑨ 城市分站10条链接齐全", c9, f"{city_ok}/10")) # 10. 友情链接:10个齐全 flink_urls = [ "eyuqi.g587.com","qyzsv.layouwei.com","mewjy.tbtnt.com", "bwfcb.xidisy.com","deqsa.773588.com","dvpru.yyc-ai.com", "ehmni.836188.com","koboj.tbtnt.com","ubjry.xmotp.com","ocrog.773588.com", ] flink_ok = sum(1 for u in flink_urls if u in html) c10 = flink_ok == 10 checks.append(("⑩ 友情链接10条齐全", c10, f"{flink_ok}/10")) # 11. 板块完整性 sections = ["首页Banner","产品展示","关于我们","应用场景","合作案例","售后服务","常见问题","城市分站","友情链接"] # 通过id检查 ids = ["home","products","about","scenario","cases","service","faq","city","links"] sec_ok = sum(1 for i in ids if f'id="{i}"' in html) c11 = sec_ok == 9 checks.append(("⑪ 九大板块(id)齐全", c11, f"{sec_ok}/9")) # 12. 响应式 viewport c12 = 'viewport' in html checks.append(("⑫ 响应式 viewport 声明", c12, "")) # 13. 汉堡菜单(移动端折叠) c13 = 'hamburger' in html and 'toggleMenu' in html checks.append(("⑬ 移动端折叠菜单(768/375)", c13, "")) print() for name, ok, detail in checks: print(f" [{'✔' if ok else '✘'}] {name} {detail}") print() all_ok = all(ok for _, ok, _ in checks) print("=" * 60) print(f"总体:{'全部通过 ✔' if all_ok else '存在问题 ✘'}") print("=" * 60) # 图片上叠加文字检查:查找 img 标签后紧跟包含文字的元素(粗略:确认没有在图片上覆盖 text 的绝对定位文字层) # 简单确认没有 内或伪元素 content 使用图片名 overlay = bool(re.search(r'img.*?::.*?content', html, re.S)) print(f"\n图片叠加文字检查(粗略): {'存在风险' if overlay else '未发现'}")