Answer the question
In order to leave comments, you need to log in
Where is the error in my C# html parser?
There is a project. Parser made according to the lesson, I am attaching a link to this project so that you can see the code for yourself. When you run the source code, the habra headers are parsed, I changed the settings for my request, but the headers are not parsed, although I definitely did everything right.
I really ask for help.
GitHub Sorce
What I did, I replaced the link class in the file in the Core/Habra/HabraParser.cs folder
from post__title_link to PreviewTooltip (the only sin is that the title class is there)
I also changed the file in the Core/habra/HabraSettings folder .cs a link to the forum itself
from https://habrahabr.ru to https://mysite/forums/252
and changed the prefix from page{CurrentId} to page-{CurrentId}
because the link comes out when you clickhttps://mysite/forums/252/page-2
I also give the full html of this block, where the link is located:
<div class="listBlock main">
<div class="titleText">
<h3 class="title"><a href="threads/61443/" title="" class="PreviewTooltip" data-previewurl="threads/61443/preview">Название темы</a></h3>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
It seems that you did not understand the parser and did not read the AngleSharp documentation.
First, how to debug the parser on https://mysite/forums? Imagine mentally, guessing intuitively?
Secondly, you want to get the value of the data-previewurl attribute, but the result is mysite.ru/threads/61443, and this is the value of another attribute - href, and in the question you say "but the headers are not parsed." You decide: Do you need a title or an attribute value, and which one?
Thirdly, if you read the documentation, you would know how to get the value of an attribute, I added it to the Parse method in your project
if (item.HasAttribute("data-previewurl"))
{
list.Add(item.GetAttribute("data-previewurl"));
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question