public Form1()
{
InitializeComponent();
InitializeChromium();
browser.FrameLoadEnd += WebBrowserFrameLoadEnded;
}
private void WebBrowserFrameLoadEnded(object sender, FrameLoadEndEventArgs e)
{
if (e.Frame.IsMain)
{
MessageBox.Show("РАБОТАЕМ!");
browser.ViewSource();
browser.GetSourceAsync().ContinueWith(taskHtml =>
{
html = taskHtml.Result;
Parce();
});
}
}
private void button1_Click(object sender, EventArgs e)
{
browser.Load($"https://kad.arbitr.ru/Card?number={textBox1.Text}");
}
private void InitializeChromium()
{
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
browser = new ChromiumWebBrowser("https://kad.arbitr.ru");
// Controls.Add(browser);
// browser.Dock = DockStyle.Fill;
}
private void Parce()
{
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
HtmlNodeCollection node = doc.DocumentNode.SelectNodes("//*[@id='gr_case_partps']/table/tbody/tr/td[1]/div/ul/li/span/a");
if(node != null)
{
node = doc.DocumentNode.SelectNodes("//*[@id='gr_case_partps']/table/tbody/tr/td[1]/div/ul/li/span/a");
Plaintiffs.Text = "Истцы:\n" + node[0].InnerText.Replace(" ", "");
node = doc.DocumentNode.SelectNodes("//*[@id='gr_case_partps']/table/tbody/tr/td[2]/div/ul/li/span/a");
defendant.Text = "Ответчики:\n" + node[0].InnerText.Replace(" ", "");
node = doc.DocumentNode.SelectNodes("//*[@id='chrono_list_content']/div/div/div[1]/div[2]/h4/span[2]/span/a");
judje.Text = "Суд:\n" + node[0].InnerText.Replace(" ", "");
}
}