Answer the question
In order to leave comments, you need to log in
Wrote a small parser, how to find an error?
There is a code that should parse a link to the newest (in time) news.
Since there are "hot" news that stay at the top, parsing just the first link is not an option.
There is such a code, it works in a timer for 3 minutes, but out of 7 new news items, it returned only 5.
Went through all the code, tell me where to dig?
public string GetLink()
{
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string result = client.DownloadString("https://crypto.ru/novosti/");
DateTime dt = DateTime.MinValue;
string link = null;
for (int i = 0; i < 4; i++)
{
string item = Pars(result, "class=\"posts-grid-news__item-info", "</a>", i);
string data = Pars(item, "posts-grid-news__item-date\">", "<", i);
string tempLink = Pars(item, "href=\"", "\"", 0);
string tempTime = data.Split(' ')[2];
string tempDate = data.Split(' ')[0] + " " + data.Split(' ')[1];
data = tempTime + " " + tempDate;
DateTime tempDT = DateTime.Parse(data);
if (tempDT > dt)
{
dt = tempDT;
link = tempLink;
}
}
return link;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question