没有项目描述

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使用McClickListener单击了什么元素   Java时间戳在Oracle时间戳中不同情况下存储12 PM的奇怪行为   java无法使用事件总线对运行在不同机器上的垂直体进行通信   java Mockserver:收到请求后进行回调   java无法将Json字符串转换为Map<string,Object>   java如何按升序排列输出?   java视图行,带有oracle键。jbo。在SrCategoryParentIterator中找不到键[300100120394155]   javafxmysql连接示例   java正在等待加载完成   java是否可以将同一个有状态会话bean实例注入多个其他会话bean?   java无法让万向节检测离开或进入区域   使用JavaCV和OpenCV的java提供了dyld:lazy符号绑定失败:找不到符号:__sincos_stret   xml解析无法使用Java读取xml文档   java无法更改工具栏的颜色   javaapachesshd和JSCH   java无法在firebase存储中检索图像url   java问题与executeUpdate   同一应用程序中不同活动之间的java SharedReference