The Connected
✅ Web Scraper
using System;
using HtmlAgilityPack;
class Program
{
static void Main(string[] args)
{
Console.Write("Enter pokemon name: ");
string pokemonName = Console.ReadLine();
string url = $"https://www.pokemon.com/uk/pokedex/{pokemonName}";
var web = new HtmlWeb();
var doc = web.Load(url);
var descriptionElement = doc.DocumentNode.SelectSingleNode("//p[contains(@class, 'version-x') and contains(@class, 'active')]");
if (descriptionElement != null)
{
string description = descriptionElement.InnerText.Trim();
Console.WriteLine(description);
Console.ReadLine();
}
else
{
Console.WriteLine("Description not found.");
Console.ReadLine();
}
}
}
using System;
using HtmlAgilityPack;
class Program
{
static void Main(string[] args)
{
Console.Write("Enter pokemon name: ");
string pokemonName = Console.ReadLine();
string url = $"https://www.pokemon.com/uk/pokedex/{pokemonName}";
var web = new HtmlWeb();
var doc = web.Load(url);
var descriptionElement = doc.DocumentNode.SelectSingleNode("//p[contains(@class, 'version-x') and contains(@class, 'active')]");
if (descriptionElement != null)
{
string description = descriptionElement.InnerText.Trim();
Console.WriteLine(description);
Console.ReadLine();
}
else
{
Console.WriteLine("Description not found.");
Console.ReadLine();
}
}
}
62 replies