using PuppeteerSharp;
// 下载内核浏览器
//await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
var browser = await Puppeteer.LaunchAsync(new LaunchOptions()
{
Headless = true
});
var page = await browser.NewPageAsync();
await page.GoToAsync("https://www.dszuqiu.com/panlu/1016229");
// 设置浏览器宽高
await page.SetViewportAsync(new ViewPortOptions
{
Width = 960,
Height = 1000,
IsMobile = false,
IsLandscape = false,
});
// 设置最大超时时间
await page.WaitForTimeoutAsync(1500);
var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var sPath = Path.Combine(desktop, "Snapshot.txt");
var content = await page.GetContentAsync();
// 网页内容输出至控制台
Console.WriteLine(content);
网友评论