系统相关
首页 > 系统相关> > CentOS 7.6.1810 运行pupperteer

CentOS 7.6.1810 运行pupperteer

作者:互联网

故障排除

安装puppeteer,使用cnpm

解决依赖

$ yum -y update
$ yum install -y pango libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr GConf2 alsa-lib atk gtk3 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc
$ yum update nss -y

执行代码

import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import * as pptr from 'puppeteer';

@Controller()
export class AppController {
        constructor(private readonly appService: AppService) {}

        @Get()
        async getHello() {
                const browser = await pptr.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
                const page = await browser.newPage();
                await page.goto("https://translate.google.cn");
                return await  page.title();
        }
}

标签:await,1810,fonts,pupperteer,7.6,yum,xorg,import,x11
来源: https://www.cnblogs.com/ajanuw/p/11026739.html