using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using HtmlAgilityPack;
namespace WindowsFormsApp12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Uri url = new Uri("https://www.dunya.com/");
WebClient client = new WebClient();
string htmlstring = client.DownloadString(url);
HtmlAgilityPack.HtmlDocument htmlbelge = new HtmlAgilityPack.HtmlDocument();
htmlbelge.OptionFixNestedTags = true;
htmlbelge.LoadHtml(htmlstring);
listBox1.Items.Add(htmlbelge.DocumentNode.SelectSingleNode("//*[@id='wrap']/div[2]/section/div/div[1]/h1").InnerText);
}
}
}
Şu hatayı alıyorum
System.NullReferenceException: 'Nesne başvurusu bir nesnenin örneğine ayarlanmadı.'
HtmlAgilityPack.HtmlNode.SelectSingleNode(...) returned null.
Html agility packi yeni öğreniyorum yardım ederseniz sevinirim.