0

我正在使用 Google Lighthouse 性能测试工具的 CLI 版本来测量大量网站的某些属性。我将结果作为 JSON 传递给 STDOUT,然后传递到一个节点脚本,该脚本将我感兴趣的值提取到一个 CSV 文件中。

收集的其中一项措施是audits.mobile-friendly.rawValue,我希望它成为通过 Google 的移动友好测试的标志。因此,假设该值true适用于移动优化网站。我为大约 2,000 个网站收集了这个值,所有网站都回来了false

这是我对命令行进行的示例调用:

lighthouse http://nytimes.com --disable-device-emulation --disable-network-throttling --chrome-flags="--headless" --output "json" --quiet --output-path "stdout" | node lighthouse_parser.js >> speed_log.csv

这是该命令的输出:

"data_url","data_score","data_total_byte_weight","data_consistently_interactive_time","data_first_interactive_time","data_is_on_https","data_redirects_http","data_mobile_friendly","timestamp"
"https://www.nytimes.com/",18.181818181818183,4211752,,18609.982,false,true,false,"2018-04-02T17:16:39-04:00"

这是我的代码lighthouse_parser.js

var moment = require('moment');
var getStdin = require('get-stdin');
var json2csv = require('json2csv');
var timestamp = moment().format();

getStdin().then(str => {
  try {
    process_files(str);
  } catch (error) {
    console.error(error);
  }
});

function process_files(this_file) {
  var obj = JSON.parse(this_file);
  var data_url = obj.url;
  var data_score = obj.score;
  var data_total_byte_weight = obj.audits['total-byte-weight'].rawValue;
  var data_consistently_interactive_time = obj.audits['consistently-interactive'].rawValue;
  var data_first_interactive_time = obj.audits['first-interactive'].rawValue;
  var data_is_on_https = obj.audits['is-on-https'].rawValue;
  var data_redirects_http = obj.audits['redirects-http'].rawValue;
  var data_mobile_friendly = obj.audits['mobile-friendly'].rawValue;
  var the_result = {
    "data_url": data_url,
    "data_score": data_score,
    "data_total_byte_weight": data_total_byte_weight,
    "data_consistently_interactive_time": data_consistently_interactive_time,
    "data_first_interactive_time": data_first_interactive_time,
    "data_is_on_https": data_is_on_https,
    "data_redirects_http": data_redirects_http,
    "data_mobile_friendly": data_mobile_friendly,
    "timestamp": timestamp,
  };
  var return_this = json2csv({
    data: the_result,
    header: false
  });
  console.log(return_this);
}

我无法在任何网站上获得一个true价值。audits.mobile-friendly.rawValue

对我做错了什么有任何想法吗?

4

1 回答 1

0

mobile-friendly您在此处查看 的审核结果是:在此处输入图像描述

它本质上是一个占位符审核,告诉您使用移动友好测试。所以,确实,它的价值永远不会改变。;)


viewport和(在content-width某种程度上)font-size审计可用于提供移动友好性的定义,这与专用 MFT 返回的内容相当。

于 2018-04-04T19:51:12.040 回答