вот код
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScrapingDollarRate
{
internal class Episode
{
public string OverallNumber { get; set; }
public string Title { get; set; }
public string Directors { get; set; }
public string WrittenBy { get; set; }
public string Released { get; set; }
}
}
using HtmlAgilityPack;
using CsvHelper;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Globalization;
namespace ScrapingDollarRate
{
class Program
{
static void Main(string[] args)
{
// the URL of the target dollar rate page
string url = "https://www.banki.ru/products/currency/usd/";
var web = new HtmlWeb();
// downloading to the target page
// and parsing its HTML content
var document = web.Load(url);
var nodes = document.DocumentNode.SelectNodes("div[class = 'Flexbox__sc-wtbhrg-0 hrHAlf']");
List<Episode> episodes = new List<Episode>();
foreach (var node in nodes)
{
// add a new Episode instance to
// to the list of scraped data
episodes.Add(new Episode()
{
OverallNumber = HtmlEntity.DeEntitize(node.SelectSingleNode("div[class = 'Text__sc-j452t5-0 hDxmZl']").InnerText),
Title = HtmlEntity.DeEntitize(node.SelectSingleNode("div[class = 'Text__sc-j452t5-0 bCCQWi']").InnerText)
});
}
// initializing the CSV file
using (var writer = new StreamWriter("output.csv"))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
// populating the CSV file
csv.WriteRecords(episodes);
}
}
}
}
выскакивает ошибка System.NullReferenceException: 'Object reference not set to an instance of an object.'