Cloud Functions puppeteer Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com

Cloud Functions puppeteer Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com

在 google Cloud Functions 上,当我尝试使用 puppeteer 时,我尝试的所有站点都出现以下错误,例如 google.com:

Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com
    at navigate (/srv/node_modules/puppeteer/lib/FrameManager.js:101:37)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
  -- ASYNC --
    at Frame.<anonymous> (/srv/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.goto (/srv/node_modules/puppeteer/lib/Page.js:656:49)
    at Page.<anonymous> (/srv/node_modules/puppeteer/lib/helper.js:111:23)
    at /srv/index.js:35:20
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)

云函数代码:

    const functions = require("firebase-functions");
    const cors = require("cors")({origin: true});
    const Firestore = require("@google-cloud/firestore");
    const puppeteer = require("puppeteer");
    const cheerio = require("cheerio");

    exports.getSiteOne = functions
      .runWith({ memory: "2GB" })
      .https.onRequest((req, res) => {
        cors(req, res, async function() {
          try {
            const browser = await puppeteer.launch({
              headless: true,
              args: ["--no-sandbox", "--disable-setuid-sandbox"]
            });
            const page = await browser.newPage();

            await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3419.0 Safari/537.36');

            await page.goto("http://www.google.com", {
              waitUntil: "networkidle0"
            });

            var html = await page.content();

            res.status(200).json({
              message: "cron added",
              html
            });
          } 
          catch (err) {
            console.log(err);
            res.status(500).json({
              error: err
            });
          }
        });
      });

人偶版本“^1.14.0”

注意:当我在本地提供它时它工作正常

错误是说 DNS 查找失败。我假设您是免费的 "Spark Plan"。那个不允许任何传出流量:

Outbound networking: Google services only