找出特定的外部网站页面是否存在(飞镖)

Finding out if a specific external website page exists (dart)

我正在尝试查明特定网页是否存在。我在 dart 文件中使用 dart:html 库,我对此信息感兴趣。

例如,我想知道是否存在这样的页面:https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement.autofocus

我怎么能在 dart 中做到这一点?

只需获取网站,如果您收到错误响应,则表明该网站不存在(或当前已关闭)。

import 'dart:html';

main() async {
  var url = 'http://www.google.com/somepage.html';
  var response = await HttpRequest.getString(url);
  // examine response for errors
}

尝试 DartPad