Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using PuppeteerSharp;
- using System;
- using System.Threading.Tasks;
- class Program
- {
- static async Task Main(string[] args)
- {
- // Initialize a browser fetcher to download PuppeteerSharp binaries
- using var browserFetcher = new BrowserFetcher();
- await browserFetcher.DownloadAsync();
- // Launch a headless browser instance with specified options
- await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
- {
- Headless = true, // Run the browser in headless mode (no GUI)
- Args = new[] { "--proxy-server=8.219.97.248:80" } // Configure the proxy server
- });
- // Create a new web page
- await using var page = await browser.NewPageAsync();
- // Navigate to target URL using the configured proxy (no proxy authentication in this code)
- await page.GoToAsync("https://httpbin.io/ip");
- // Retrieve the content of the web page
- var pageContent = await page.GetContentAsync();
- // Print the page content (in this case, the IP address)
- Console.WriteLine(pageContent);
- // Close the browser when finished
- await browser.CloseAsync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement