Google chrome devtools 将字体url映射到字体名称
如何使用Puppeter根据字体url获取字体名称 我正在使用Google chrome devtools 将字体url映射到字体名称,google-chrome-devtools,puppeteer,Google Chrome Devtools,Puppeteer,如何使用Puppeter根据字体url获取字体名称 我正在使用Network.requestIntercepted获取给定网站上使用的字体列表。但是,响应不包含有关CSS中使用的字体系列的任何信息 有没有办法获取字体系列名称和页面上使用的相应字体url await client.on('Network.requestIntercepted', async e => { if (e.resourceType == "Font") { console.log(e)
Network.requestIntercepted
获取给定网站上使用的字体列表。但是,响应不包含有关CSS中使用的字体系列的任何信息
有没有办法获取字体系列名称和页面上使用的相应字体url
await client.on('Network.requestIntercepted', async e => {
if (e.resourceType == "Font") {
console.log(e)
fontCollection.add(e.request.url)
}
虽然响应包含字体详细信息,但不包含字体系列名称
{ interceptionId: 'interception-job-14.0',
request:
{ url:
'https://fonts.gstatic.com/s/lato/v15/S6uyw4BMUTPHjx4wWyWtFCc.ttf',
method: 'GET',
headers:
{ Origin: 'https://goldrate.com',
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/73.0.3679.0 Safari/537.36',
Accept: '*/*',
Referer:
'https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i' },
initialPriority: 'VeryHigh',
referrerPolicy: 'no-referrer-when-downgrade' },
frameId: '4127ABB5A3E704843D0AB4756C7507E4',
resourceType: 'Font',
isNavigationRequest: false }
您有两个选择:
- 网址 font.gstatic.com/s/lato/v15/s6uyw4bmutphjx4wwwytfcc.ttf
- 推荐人: fonts.googleapis.com/css?family=Lato:100100i、300300i、400400i、700700i、900900i
ttf
文件并读取其类似的familyName
或fullName
:
代码示例
const fetch=require('node-fetch');
const fontkit=require('fontkit');
(异步()=>{
const response=等待获取('https://fonts.gstatic.com/s/lato/v15/S6uyw4BMUTPHjx4wWyWtFCc.ttf');
const buffer=等待响应。buffer();
const font=fontkit.create(缓冲区);
console.log(font.familyName);/“Lato”
console.log(font.fullName);/“Lato-Regular”
})();
然后,您可以在网络中执行此操作。requestIntercepted
块可找出正在使用的字体。您有两个选项:
- 网址 font.gstatic.com/s/lato/v15/s6uyw4bmutphjx4wwwytfcc.ttf
- 推荐人: fonts.googleapis.com/css?family=Lato:100100i、300300i、400400i、700700i、900900i
ttf
文件并读取其类似的familyName
或fullName
:
代码示例
const fetch=require('node-fetch');
const fontkit=require('fontkit');
(异步()=>{
const response=等待获取('https://fonts.gstatic.com/s/lato/v15/S6uyw4BMUTPHjx4wWyWtFCc.ttf');
const buffer=等待响应。buffer();
const font=fontkit.create(缓冲区);
console.log(font.familyName);/“Lato”
console.log(font.fullName);/“Lato-Regular”
})();
然后,您可以在
网络中执行此操作。requestIntercepted
块可以找出正在使用的字体。一个选项是解析引用器
,并尝试通过regex推断字体系列的名称。一个选项是解析引用器
并尝试通过regex推断字体系列的名称。