Collecting YouTube links from a page I wrote code for my needs (i.e. collecting YouTube links from a page) and it is simple, but now I just want to know what can I do just to make it a better and properly written one. For example, I think I should have try/catch blocks/exceptions in my methods, or get/set properties. What tests can I write to test the code? I don't know to be honest, but how would the code look if you had written it?

public class Parser
{
    public static void Main()
    {
        Console.WriteLine("Enter the url of the page:");
        var url = Console.ReadLine();

        var numOfPages = GetNumberOfPages(url);
        var numOfLinks = 1;

        for (int page = 0; page &lt;= numOfPages; page++)
        {
            if (page != 1)
            {
                if (page == 0)
                {
                    GetYouTubeLink(url).ForEach(x =&gt; Console.WriteLine($"{numOfLinks++}." +
                        $"{x.Replace("embed/", "watch?v=").Replace("?feature=oembed", "")}"));
                }
                else
                {
                    var newUrl = url + string.Format($"{page}/");
                    GetYouTubeLink(newUrl).ForEach(x =&gt; Console.WriteLine($"{numOfLinks++}." +
                        $"{x.Replace("embed/", "watch?v=").Replace("?feature=oembed", "")}"));
                    newUrl = string.Empty;
                }
            }
        }
    }

    private static HtmlDocument GetWebPageHtmlFromUrl(string url)
    {
        var webGet = new HtmlWeb();

        return webGet.Load(url);
    }

    private static int GetNumberOfPages(string url)
    {
        var pages = GetWebPageHtmlFromUrl(url)
            .DocumentNode.SelectNodes("//div[@class='page-link']")
            .Descendants("a")
            .Last().InnerText;

        return int.Parse(pages);
    }

    private static List&lt;string&gt; GetYouTubeLink(string url)
    {
        var links = new List&lt;string&gt;();
        var iframeLinks = GetWebPageHtmlFromUrl(url).DocumentNode.SelectNodes("//iframe");

        if (iframeLinks != null)
        {
            foreach (var link in iframeLinks)
            {
                links.Add(link.Attributes["src"].Value);
            }
        }

        return links;
    }
}
Comments inline:

public class Parser
{
    public static void Main()
    {
        Console.WriteLine("Enter the url of the page:");
        var url = Console.ReadLine();

        var numOfPages = GetNumberOfPages(url);
        var numOfLinks = 1;

        for (int page = 0; page &lt;= numOfPages; page++)
        {
            // if (page != 1) is redundant in the original code, did you mean numOfPages?
            var newUrl = url + (page &gt; 0 ? string.Format($"{page}/") : "");
            GetYouTubeLinks(newUrl).ForEach(x =&gt; Console.WriteLine($"{numOfLinks++}." +
                x.Replace("embed/", "watch?v=").Replace("?feature=oembed", "")));   // remove string interpolation since it's just one value
            // newUrl = string.Empty;       // Not needed
        }
    }

    private static HtmlDocument GetWebPageHtmlFromUrl(string url)
    {
        var webGet = new HtmlWeb();

        return webGet.Load(url);
    }

    private static int GetNumberOfPages(string url)
    {
        var pages = GetWebPageHtmlFromUrl(url)
            .DocumentNode.SelectNodes("//div[@class='page-link']")  // This parsing may work on specific pages, but it won't work on all pages. This is concerning since the user is prompted to enter any URL?
            .Descendants("a")
            .Last().InnerText;

        return int.Parse(pages);
    }

    private static List&lt;string&gt; GetYouTubeLinks(string url)     // Made plural
    {
        var iframeLinks = GetWebPageHtmlFromUrl(url).DocumentNode.SelectNodes("//iframe");

        if (iframeLinks == null)    // reduce nesting
        {
            return new List&lt;string&gt;(0);
        }

        return iframeLinks.Select(link =&gt; link.Attributes["src"].Value).ToList();   // simplify allocation
    }
}