获取网页标题

async function getTitle(url) {
  let response = await fetch(url);
  let html = await response.text();
  return html.match(/<title>([\s\S]+)<\/title>/i)[1];
}
getTitle('https://tc39.github.io/ecma262/').then(console.log)

http://es6.ruanyifeng.com/#docs/async

posted on 2019-10-26 09:37  长孙同学  阅读(97)  评论(0)    收藏  举报

导航