没有项目描述

Online-W3C-Validator的Python项目详细描述


使用W3C在线验证器进行HTML验证的纯Python命令行。 在ci管道中使用它可能非常方便。

安装

pip install -U Online-W3C-Validator

如何使用

您可以使用cli命令:

w3c_validator http://www.google.com some_file.html

示例输出:

INFO:w3c_validator.validator:Files to validate:
  http://www.google.com
INFO:w3c_validator.validator:Number of files: 1
INFO:w3c_validator.validator:validating: http://www.google.com ...
error: line 2: CSS: “display”: “inline-box” is not a “display” value in “inline-box” in “.ds”.
error: line 2: The “bgcolor” attribute on the “body” element is obsolete. Use CSS instead.
error: line 5: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.)
error: line 5: Attribute “width” not allowed on element “div” at this point.
error: line 5: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.)
error: line 5: The “center” element is obsolete. Use CSS instead.
error: line 5: The “clear” attribute on the “br” element is obsolete. Use CSS instead.

或者可以使用包提供的函数validdate 将html文件名或url作为单个参数返回 带有验证输出的json对象。

fromw3c_validatorimportvalidatemessages=validate("http://www.google.com")["messages"]forminmessages:print("Type: %(type)s, Line: %(lastLine)d, Description: %(message)s"%m)

示例输出:

Type: error, Line: 2, Description: CSS: “display”: “inline-box” is not a “display” value in “inline-box” in “.ds”.
Type: error, Line: 2, Description: The “bgcolor” attribute on the “body” element is obsolete. Use CSS instead.
Type: error, Line: 5, Description: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.)
Type: error, Line: 5, Description: Attribute “width” not allowed on element “div” at this point.
Type: error, Line: 5, Description: Element “nobr” not allowed as child of element “div” in this context. (Suppressing further errors from this subtree.)
Type: error, Line: 5, Description: The “center” element is obsolete. Use CSS instead.
Type: error, Line: 5, Description: The “clear” attribute on the “br” element is obsolete. Use CSS instead.
Type: error, Line: 5, Description: The “align” attribute on the “div” element is obsolete. Use CSS instead.
Type: error, Line: 5, Description: Attribute “nowrap” not allowed on element “div” at this point.
...

联系人

对于错误,请使用GitHub issues其他事情请随意 在nad2000@gmail.com联系我。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何拆分字符串(基于各种分隔符),但不保留空格?   解析。Json格式的txt文件和knime中的java   java Spring rest api为什么在rest api调用的响应中更改了数据类型   升华文本3抛出java。lang.ClassNotFoundException,而记事本++不存在   java Android指纹扫描仪在尝试5次后停止工作?   java Android如何设置精确的重复报警?   java如何使用HTTPGET connect为access API输入用户名和密码   java当测试报告显示没有测试失败时,Gradle为什么说“有失败的测试”?   用Gson实现java获取响应   MapReduce程序中函数错误的java不可映射参数   java spring安全性不符合自动代理的条件   java GWT使用异步回调进行同步/阻塞调用   java奇怪的类数组问题无法在jsp中显示   如何在java中使用PrinterJob使用epl打印条形码   java如何在JTable中居中单元格   将Java Mockito测试转换为Kotlin   html Java正则表达式模式匹配到多个相同标记   testCompile中缺少java Gradle(Android)多项目依赖项   在输入提示后输入字符串时发生java FileNotFoundException