Advertisement
dereksir

Untitled

Oct 16th, 2023 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using PuppeteerSharp;
  2. using System;
  3. using System.Threading.Tasks;
  4.  
  5. class Program
  6. {
  7.     static async Task Main(string[] args)
  8.     {
  9.         // Define the ZenRows API URL
  10.         string zenRowsApiUrl = "https://api.zenrows.com/v1/?apikey=<YOUR_ZENROWS_API_KEY>&url=https%3A%2F%2Fwww.g2.com%2F&js_render=true&antibot=true&premium_proxy=true";
  11.  
  12.         using var browserFetcher = new BrowserFetcher();
  13.         await browserFetcher.DownloadAsync();
  14.  
  15.         var browser = await Puppeteer.LaunchAsync(new LaunchOptions
  16.         {
  17.             Headless = true
  18.         });
  19.  
  20.         var page = await browser.NewPageAsync();
  21.  
  22.         // Send a request to the ZenRows API
  23.         await page.GoToAsync(zenRowsApiUrl);
  24.  
  25.         // Retreive page content
  26.         var pageContent = await page.GetContentAsync();
  27.         Console.WriteLine(pageContent);
  28.  
  29.         await browser.CloseAsync();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement