Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import the required package
- using PuppeteerSharp;
- class Program
- {
- static async Task Main(string[] args)
- {
- using var browserFetcher = new BrowserFetcher();
- await browserFetcher.DownloadAsync();
- // launch a new headless browser instance
- await using var browser = await Puppeteer.LaunchAsync(
- new LaunchOptions { Headless = true });
- // open a new browser page
- await using var page = await browser.NewPageAsync();
- // navigate to target website
- await page.GoToAsync("https://scrapeme.live/shop/Pikachu/");
- // extract product price
- var productPrice = await page.EvaluateExpressionAsync<string>(
- "document.querySelector('#product-752 > div.summary.entry-summary > p.price > span').innerText");
- // print the product price
- Console.WriteLine("Product Price: " + productPrice);
- // close the browser when done
- await browser.CloseAsync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement