The Connected
The Connected
CC#
Created by The Connected on 3/29/2024 in #help
✅ 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();
}
}
}
Why isn't this working?
62 replies