private Logradouro GetString(string html) { Regex r = new Regex(@"<span(.*?)class=""resposta(.*?)"">(.*?)</span>"); MatchCollection mc = r.Matches(html.Replace("\t", " ").Replace("\r\n", "").Replace("\n", "").Replace("\r", "").Replace(" ", " ").Replace(" ", " ").Replace(":", "")); html = String.Empty; Logradouro log = new Logradouro(); for (int i = 0; i < mc.Count; i++) { Match m = mc[i]; switch (i) { case 1: log.Endereco = m.Groups[3].Value.Trim(); break; case 3: log.Bairro = m.Groups[3].Value.Trim(); break; case 5: log.Localidade = m.Groups[3].Value.Trim(); break; case 7: log.Cep = m.Groups[3].Value.Trim(); break; } } return log; }
public ActionResult DadosLogradouro(string id) { Logradouro log = new Logradouro(); return Json(log.RecuperaCep(id),JsonRequestBehavior.AllowGet); }