I've found Fizzler as html parser and jQuery like selector . But seems visual studio can not resolve QuerySelectorAll
method.
here is my code :
using HtmlAgilityPack;
HtmlAgilityPack.HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument document = web.Load(url);
var c = document.QuerySelectorAll('div');
did I miss any references ?
EDIT : after some search I found this code for using Fizzler
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
const string search = "td";
SelectorGenerator<HtmlNode> selectorGenerator1 = new SelectorGenerator<HtmlNode>(new HtmlNodeOps());
HumanReadableSelectorGenerator selectorGenerator2 = new HumanReadableSelectorGenerator();
Parser.Parse(search, new SelectorGeneratorTee(selectorGenerator1, selectorGenerator2));
var c = selectorGenerator1.Selector(Enumerable.Repeat(doc.DocumentNode, 1)).ToList();
I'm still looking for find good answer for my question.
Probably this:
using Fizzler.Systems.HtmlAgilityPack;
Also give a shot to CsQuery, my C# jQuery port: https://github.com/jamietre/CsQuery
var dom = CQ.CreateFromUrl(url);
var c = dom["div"];
.. plus everything you're used to from jQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With