//Формируем таблицу базы public void GetDb(string[] array) { //Пробегаемся по всем html адресам из списка и заполняем таблицу TableHelper th = new TableHelper(true); if (Program.myForm.InvokeRequired) Program.myForm.Invoke((Action)(() => { Program.myForm.label1.Text = "Формирование таблицы базы данных..."; Program.myForm.progressBar.Visible = true; Program.myForm.progressBar.Minimum = 0; Program.myForm.progressBar.Maximum = array.Length - 1; })); for (int i = 0; i < array.Length; i++) { string choosenVacancy = HtmlDownloadHelper.DownloadHtml(array[i], Encoding.GetEncoding(65001)); TextSearcher ts = new TextSearcher(choosenVacancy); ts.Skip("<title>"); vacancy = ts.ReadTo(":"); ts.Skip("description\" content=\""); description = ts.ReadTo("\""); th.DbAddRow(date, vacancy, salary, description); if (Program.myForm.InvokeRequired) Program.myForm.Invoke((Action)(() => Program.myForm.progressBar.Value = i)); } //Записываем полученную таблицу в базу. Все. if (Program.myForm.InvokeRequired) Program.myForm.Invoke((Action)(() => { Program.myForm.label1.Text = "Сохранение базы данных..."; Program.myForm.progressBar.Visible = false; })); dbModification(connectionString, sql, th.table, true); if (Program.myForm.InvokeRequired) Program.myForm.Invoke((Action)(() => Program.myForm.label1.Text = "Готово")); }
public void FindVacancy(string id) { string vacancyUri = string.Format(@"https://ekb.zarplata.ru/vacancy?rubric_id[]={0}&limit=50", id); string vacancyHtml = HtmlDownloadHelper.DownloadHtml(vacancyUri, Encoding.GetEncoding(65001)); TextSearcher ts = new TextSearcher(vacancyHtml); vacancyHtml = ts.Crop("<a href=\"/vacancy/", "<a href=\"/vacancy/extended"); int dimension = new Regex("<a href=\"/vacancy/").Matches(vacancyHtml).Count; vacancyArray = new string[dimension]; Array.Clear(vacancyArray, 0, dimension); if (Program.myForm.InvokeRequired) { Program.myForm.Invoke((Action)(() => Program.myForm.label1.Text = "Построение списка всех вакансий...")); } for (int i = 0; i < vacancyArray.Length; i++) { ts.Skip("<a href=\"/vacancy/"); vacancyArray[i] = "https://ekb.zarplata.ru/vacancy/" + ts.ReadTo("\""); } if (Program.myForm.InvokeRequired) { Program.myForm.Invoke((Action)(() => Program.myForm.label1.Text = "Список построен...")); } }
public void FindVacancyList() { if (string.IsNullOrEmpty(myHtml)) { throw new MyFirstParserException("Код html не был загружен. Сначала выполните download html"); } TextSearcher ts = new TextSearcher(myHtml); TableHelper th = new TableHelper(); while (ts.Skip("vacancy?rubric_id[]=")) { string thisId = ts.ReadTo("\""); ts.Skip(">"); string thisItem = ts.ReadTo("<"); th.AddRow(thisId, thisItem); } Program.myForm.label2.Text = "Готово"; Program.myForm.comboBox1.DataSource = th.table; Program.myForm.comboBox1.DisplayMember = "Item"; }