Advertisement
dereksir

Untitled

Oct 16th, 2023 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using PuppeteerSharp;
  2. using System;
  3.  
  4. class Program
  5. {
  6.     static async Task Main(string[] args)
  7.     {
  8.         using var browserFetcher = new BrowserFetcher();
  9.         await browserFetcher.DownloadAsync();
  10.  
  11.         await using var browser = await Puppeteer.LaunchAsync(
  12.             new LaunchOptions { Headless = true });
  13.  
  14.         await using var page = await browser.NewPageAsync();
  15.  
  16.         await page.GoToAsync("https://httpbin.io/ip");
  17.  
  18.         // Get the content of the page
  19.         var pageContent = await page.GetContentAsync();
  20.  
  21.         // Print the page content
  22.         Console.WriteLine(pageContent);
  23.  
  24.         // Close the browser when done
  25.         await browser.CloseAsync();
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement