- Using cefsharp I loaded a page that gives 25 links in a page.
- using
FrameLoadEnd
got HTML content into HtmlAgilityPack Document. - Got title from nodes for 25 links. Problem When i click for 50 links on page and try to get titles, it still gives me 25 links. which is old page. i could not figureout why FrameLoadEnd is not able to change the html when navigated to another link within page.
When I click 50 titles i cannot get the html content for 50 titles
here is code
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 CefSharp;
using CefSharp.WinForms;
using System.Windows.Forms;
using HtmlAgilityPack;
namespace Hummingbird_HAP_E_Scraper
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
chromiumWebBrowser1.Load("https://www.sciencedirect.com/search?qs=nursing");
}
string html;
private void ChromiumWebBrowser1_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
{
BeginInvoke((Action)(async () =>
{
html = await chromiumWebBrowser1.GetSourceAsync();
}));
}
HtmlAgilityPack.HtmlDocument xdoc = new HtmlAgilityPack.HtmlDocument();
private void Button1_Click(object sender, EventArgs e)
{
xdoc.LoadHtml(html);
System.Threading.Thread.Sleep(5000);
HtmlNodeCollection links;
links = xdoc.DocumentNode.SelectNodes("//h2/span/a");
if (links == null)
return;
foreach (HtmlNode link in links)
{
listBox1.Items.Add(link.InnerText);
}
}
}
}