0
我没有使用web视图,以获得完整的页面源和我把它写入一个文件如何从pagesource所有的img标签与anglesharp
所以现在我需要从文件中提取的所有图像
我读使用的StreamReader的文件,我给它叫TheHtmlSource你在代码中看到的字符串
这是我的代码
var config = Configuration.Default.WithDefaultLoader();
for (int i = 0; i < TheHtmlSource.Length; i++)
{
string theImageUrl = (await BrowsingContext.New(config).OpenAsync(TheHtmlSource))
.DocumentElement.Descendents()
.Where(x => x.NodeType == NodeType.Element)
.OfType<IHtmlImageElement>()
.Where(x => x.Attributes["class"]?.Value == "_icyx7")
.Select(x => x.Attributes["src"]?.Value)
.FirstOrDefault();
int index = theImageUrl.IndexOf("?");
string fixedImageUrl = theImageUrl.Remove(index);
_list.Add(new AllImageUrls()
{
url = fixedImageUrl
});
}
,但我不工作,我不断收到ñ使用Xamarin在Visual Studio
任何帮助将ullReference错误
IM不胜感激
你能发表一个标签,你试图获得img的价值吗? – Yupi
.OfType()img with calss =“_ icyx7”选择Src –
您是否发布了整个标签?这是非常重要的,它之间有空格或命名空间 – Yupi