trenoncourt / HtmlAgilityPack.CssSelectors.NetCore

NetStandard version of HtmlAgilityPack.CssSelector
33 stars 17 forks source link

System.InvalidOperationException: Sequence contains no elements #6

Open mushramb0 opened 6 years ago

mushramb0 commented 6 years ago

hi,my ide is vs2017,netcore 2.1,c#7.3 when i run this code,it throw a exception Console.WriteLine($"{itt.QuerySelectorAll("img.img[width]")?.Count()}"); Console.WriteLine($"{itt.QuerySelectorAll("img.img[height]")?.Count()}"); Console.WriteLine($"{itt.QuerySelectorAll("img.img[width][height]")?.Count()}"); output is 3 3 System.InvalidOperationException: Sequence contains no elements at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at HtmlAgilityPack.CssSelectors.NetCore.Token..ctor(String word) at HtmlAgilityPack.CssSelectors.NetCore.Token.<>c.<.ctor>b__8_0(String i) at System.Linq.Enumerable.SelectListPartitionIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at HtmlAgilityPack.CssSelectors.NetCore.Token..ctor(String word) at HtmlAgilityPack.CssSelectors.NetCore.Tokenizer.GetTokens(String cssFilter)+MoveNext() at System.Linq.Enumerable.SelectEnumerableIterator2.ToList() at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at HtmlAgilityPack.CssSelectors.NetCore.HapCssExtensionMethods.QuerySelectorAll(IEnumerable1 nodes, String cssSelector) it seems not support css [][]

akaero commented 5 years ago

have same problem

BoricuaEnLaLuna commented 5 years ago

I have addressed this issue in my PR here: https://github.com/trenoncourt/HtmlAgilityPack.CssSelectors.NetCore/pull/9

Hopefully someone with privileges merges this into master