Skip to content

Instantly share code, notes, and snippets.

@Seregamil
Created July 9, 2019 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seregamil/9073696df26728cb65fb1e65c6df9588 to your computer and use it in GitHub Desktop.
Save Seregamil/9073696df26728cb65fb1e65c6df9588 to your computer and use it in GitHub Desktop.
asuParserResults
/*
* Created by SharpDevelop.
* User: Seregamil
* Date: 09.07.2019
* Time: 10:58
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Text;
using System.Net;
using HtmlAgilityPack;
using System.Collections.Generic;
using System.Linq;
namespace asuRatings
{
class Program
{
public static void Main(string[] args)
{
//http://abiturient.asu.ru/ratings/list/34/121/ Химия. Квантовые технологии, компьютерный наноинжиниринг и физикохимия материалов
//http://abiturient.asu.ru/ratings/list/34/122/ Химия. Химико-аналитический контроль живых и техносферных систем
//http://abiturient.asu.ru/ratings/list/33/107/ Информатика и вычислительная техника. Нейроинформационные технологии и робототехнические системы
WebClient webClient = new WebClient();
string page = webClient.DownloadString("http://abiturient.asu.ru/ratings/list/33/107/");
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(page);
List<List<string>> table = doc.DocumentNode.SelectSingleNode("//table[@class='align_top']")
.Descendants("tr")
.Skip(1)
.Where(tr=>tr.Elements("td").Count() > 1)
.Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
.ToList();
foreach(var val in table) {
var temp = val.ToArray();
int id = -1;
bool stop = false;
string result = string.Empty;
foreach(var valtemp in temp) {
id++;
if(id == 0 || id == 2 || id == 4)
continue;
string h = valtemp;
byte[] toEncodeAsBytes = Encoding.Default.GetBytes(h);
string returnValue = Encoding.UTF8.GetString(toEncodeAsBytes);
string sub = string.Empty;
if(returnValue.Length < 24)
sub = "\t\t";
else
sub = "\t";
result = result + returnValue + sub;
if(returnValue.Contains("Милантьев"))
stop = true;
//stringResult = stringResult + returnValue + "\t";
}
id = -1;
Console.WriteLine(result);
result = string.Empty;
if(stop == true)
break;
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment