Advertisement
dereksir

Untitled

Nov 27th, 2023 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using AngleSharp
  2.  
  3. class Scraper
  4. {
  5.     static async Task Main()
  6.     {
  7.         //..
  8.  
  9.         {
  10.             //..
  11.  
  12.             // Querying for the first Pokémon element
  13.             var firstPokemon = document.QuerySelector(".post-759");
  14.  
  15.             // Checking if a Pokémon element is found
  16.             if (firstPokemon != null)
  17.             {
  18.                 // Extracting Pokémon information: name, price, and image
  19.                 string name = firstPokemon.QuerySelector("h2")?.TextContent ?? "Not available";
  20.                 string price = firstPokemon.QuerySelector(".price")?.TextContent ?? "Not available";
  21.                 string image = firstPokemon.QuerySelector("img")?.GetAttribute("src") ?? "Not available";
  22.  
  23.                 Console.WriteLine($"Pokémon Name: {name}");
  24.                 Console.WriteLine($"Pokémon Price: {price}");
  25.                 Console.WriteLine($"Pokémon Image: {image}");
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement