css - node.js、css 验证、w3c 禁止我?

标签 css node.js gulp w3c-validation

我提前为我通过翻译写的内容道歉,我的英语很差。

我遇到了以下问题:我需要执行验证 css 文件。为此,我决定使用 NPM 包 w3c-css ,首先它起作用了,但随后开始给出“connected etimedout”,在研究过程中,我注意到通过浏览器和验证器停止工作。

脚本开始时的嗅探器日志:link (<10 代表:()

我的代码:

gulp.task('css', function() {
  gulp.src('dev/sass/*.scss')
    .pipe(through2.obj(function(file, enc, cb){
      w3c_css.validate({text: file.contents.toString('utf8')}, function(err, data) {
        if(err) {
          // an error happened
          console.error(err);
        } else {
          // validation errors
          console.log('validation errors', data.errors);

          // validation warnings
          console.log('validation warnings', data.warnings);
        }

      });
      cb(null, file);
    }))
    .pipe(gulp.dest('build/'));
});

这是什么原因?这一定是有什么错误,或者我由于请求太频繁而被阻止并且它没有改变?也许还有其他方法可以检查 css 文件?

谢谢!

最佳答案

来自 W3C 的 CSS 验证服务的“About”页面:

Can I build an application upon this validator? Is there an API?
Yes, and yes. The CSS Validator has a (RESTful) SOAP interface which should make it reasonably easy to build applications (Web or otherwise) upon it. Good manners and respectful usage of shared resources are of course customary: make sure your applications sleep() between calls to the validator, or install and run your own instance of the validator.

是的,看来您已被禁止。

我不知道如何让一个gulp任务不时被调用。你可以mount a local version of the CSS Validator webserviceediting the w3c-css package指向您自己的服务器。

关于css - node.js、css 验证、w3c 禁止我?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29484947/

相关文章:

node.js - Node 热敏打印机未连接到 Epson T88IV 打印机

gulp - 在 gulp 中复制文件时可以删除文件夹结构吗?

javascript - Firefox 6 的平滑 CSS3 转换问题

node.js - 在nodejs中查询leveldb数据库中的值

javascript - window.scrollTo 在 iframe 中使用时不起作用

node.js - 使用 PATCH 修改 Node/ Mongoose 的多个条目?

css - 使用 wiredep 注入(inject)自定义 CSS

variables - 生成多个样式表以 gulp

css - 如何为图形元素 (CSS) 中的 img 元素创建样式规则

html - 如何使div填充高度直到下一个绝对定位元素