作为Web服务运行时,Puppeteer-sharp挂起

时间:2019-04-01 15:44:09

标签: c# web-services puppeteer-sharp

我想在IIS环境中部署的Web服务中使用puppeteer-sharp库。

我已经知道铬的下载已成功(我可以在计算机上找到该文件)。不幸的是,据调试了解,任务bf.DownloadAsync不会终止。

        [Route("f")]
        [HttpGet]
        public void F()
        {
            g().Wait();
        }

        public static async Task g()
        {
            BrowserFetcher bf = new BrowserFetcher(new BrowserFetcherOptions()
            {
                Path = "C:/Users/user/Downloads"
            });
            await bf.DownloadAsync(BrowserFetcher.DefaultRevision);
            var browser = await Puppeteer.LaunchAsync(new LaunchOptions
            {
                Headless = true
            });
            var page = await browser.NewPageAsync();
            await page.GoToAsync("http://www.google.com");
            await page.ScreenshotAsync("C:/Users/user/Downloads/myOutPutFile.png");
        }

[Route("f")] [HttpGet] public void F() { g().Wait(); } public static async Task g() { BrowserFetcher bf = new BrowserFetcher(new BrowserFetcherOptions() { Path = "C:/Users/user/Downloads" }); await bf.DownloadAsync(BrowserFetcher.DefaultRevision); var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }); var page = await browser.NewPageAsync(); await page.GoToAsync("http://www.google.com"); await page.ScreenshotAsync("C:/Users/user/Downloads/myOutPutFile.png"); }

我希望任务终止,从而在我的下载目录中生成png文件。实际结果是bf.DownloadAsync永不终止。

0 个答案:

没有答案