Поправьте код для парсинга HTML-страницы - C#
Формулировка задачи:
<tr class="itr"> <td class="itdh" align="center">4</td> <td class="itd_lb" width="33%" nowrap align="left"> <a href="index.php?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=16259" target="_blank">Platform Support Specialist, Limassol, Ref:30797</a><br/><span style="font-size: 10px; color: #8F8F8F;">Last Updated: 06/18/2012</span> </td> <td class="itd_lb" width="30%" align="left">Limassol</td> <td class="itd_lb" width="33%" align="left"><strong>AP Group / AP Technical</strong></td> </tr>
index.php?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=
var request = WebRequest.Create("http://www.cyprusjobs.com/index.php?module_page=my_jobs&jobs_step=jobs_job_list");
using (var responses = request.GetResponse())
{
using (var streams = responses.GetResponseStream())
using (var readers = new StreamReader(streams))
{
string html = readers.ReadToEnd();
//var UpdExp = new Regex(@"index.php?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=(?<upd>.*)");
var UpdExp = new Regex(@"index.php?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=(?<upd>.*)""\s*[^>]*");
string upDate = UpdExp.Match(html).Groups["upd"].Value;
Label1.Text = upDate;
TextBox2.Text = upDate;
}
}Решение задачи: «Поправьте код для парсинга HTML-страницы»
textual
Листинг программы
var request = WebRequest.Create("http://www.cyprusjobs.com/index.php?module_page=my_jobs&jobs_step=jobs_job_list");
using (var responses = request.GetResponse())
{
using (var streams = responses.GetResponseStream())
using (var readers = new StreamReader(streams))
{
string html = readers.ReadToEnd();
//var UpdExp = new Regex(@"index.php?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=(?<upd>.*)");
var updExp = new Regex(@"index\.php\?module_page=my_jobs&jobs_step=jobs_details&job_jobs_id=(?<upd>\d*)""");
MatchCollection mc = updExp.Matches(html);
foreach (Match m in mc)
{
textBox1.Text += m.Groups["upd"].Value + Environment.NewLine;
}
}
}