Ejemplo n.º 1
0
        public void ShouldWork()
        {
            var executablePath = Puppeteer.GetExecutablePath();

            Assert.True(File.Exists(executablePath));
            Assert.Equal(new FileInfo(executablePath).FullName, executablePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取页面内容
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public async Task <string> GetPageContentAsync(string url)
        {
            string result = string.Empty;

            await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
            string i = Puppeteer.GetExecutablePath();

            using (Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions {
                Headless = true, IgnoreHTTPSErrors = true
            }))
            {
                using Page page = await browser.NewPageAsync();

                await page.GoToAsync(url);

                result = await page.GetContentAsync();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public void ShouldWork()
        {
            var executablePath = Puppeteer.GetExecutablePath();

            Assert.True(File.Exists(executablePath));
        }