Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Playwright;
- using System.Threading.Tasks;
- class Program
- {
- static async Task Main(string[] args)
- {
- // launch Playwright
- using var playwright = await Playwright.CreateAsync();
- // launch Chromium browser
- await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true });
- // create a new page
- var page = await browser.NewPageAsync();
- // navigate to the scrapeme website
- await page.GotoAsync("https://scrapeme.live/shop/Pikachu/");
- // extract the product price
- var priceElement = await page.QuerySelectorAsync("#product-752 > div.summary.entry-summary > p.price > span");
- var productPrice = await priceElement.InnerTextAsync();
- // print the product price
- Console.WriteLine($"Product Price: {productPrice}");
- // close the browser
- await browser.CloseAsync();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement