K
K
Kirill2020-06-25 20:57:42
Parsing
Kirill, 2020-06-25 20:57:42

How to parse src attribute in img tag via AngleSharp C#?

I need to parse an image link with a specific class.
For example: How to extract imgLink to src from img using AngleSharp? I did this with plain text:
<img class="imgClass" src="imgLink">


IEnumerable<IElement> title = document.QuerySelectorAll("span.bOpxk49");


I would be grateful for any help :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sergey, 2020-06-25
kuzmin @sergueik

Have you tried reading the documentation?
https://github.com/AngleSharp/AngleSharp/blob/mast...
specifically
Getting Certain Elements
...
//Or directly with CSS selectors
var blueListItemsCssSelector = document.QuerySelectorAll("li.blue");
?

P
Planet_93, 2020-06-25
@Planet_93

Try like this:

var menuPics = document.QuerySelectorAll("img.imgClass")
    .Select(el => el.GetAttribute("src")).ToArray();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question