Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using AngleSharp;
- class Scraper
- {
- static async Task Main()
- {
- string url = "https://scrapeme.live/shop/";
- using (HttpClient client = new HttpClient())
- {
- HttpResponseMessage response = await client.GetAsync(url);
- string htmlContent = await response.Content.ReadAsStringAsync();
- // Create an AngleSharp configuration
- var config = Configuration.Default.WithDefaultLoader();
- // Create browser session using config
- var context = BrowsingContext.New(config);
- // Load HTML into Anglesharp
- var document = await context.OpenAsync(req => req.Content(htmlContent));
- // Query for page title
- string pageTitle = document.QuerySelector("title")?.TextContent ?? "Not available";
- Console.WriteLine(pageTitle);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement