-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetallado.php
40 lines (36 loc) · 1.57 KB
/
detallado.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// header("Content-Type: text/html; charset=UTF-8");
include('lib/simple_html_dom.php');
$ruta = 'https://tribunalelectronico.ramajudicial.pr/dirabogados/Search.aspx?d=';
echo (!empty($_GET['d'])) ? datosDetallado($ruta.=$_GET['d']) : '{"error":"Error al Recibir Abogado"}';
function datosDetallado($ruta){
$datos=[];
$validar = @file_get_contents($ruta);
if(!$validar){return '{"msj":"Error al Recuperar datos del Abogado '.$_GET['d'].' "}';}
$html = file_get_html($ruta);
$lista = $html->find('span[id="lblSearchResultDetail"]');
$table = $lista[0]->find('table');
$tr = $table[0]->find('tr');
foreach($tr as $t){
$td = $t->find('td');
if(strpos($td[0]->plaintext,'ombre')){
$nombreArr = explode(',', $td[1]->plaintext);
$datos["nombre"]= $nombreArr[1].' '.$nombreArr[0];
}
if(strpos($td[0]->plaintext,'mail')){
$datos["correo"]= $td[1]->plaintext;
}
if(strpos($td[0]->plaintext,'fono')){
$datos["telefono"]=$td[1]->plaintext;
}
}
$datos = json_encode($datos);
$datos = str_replace("Á","Á",$datos);
$datos = str_replace("É","É",$datos);
$datos = str_replace("Í","Í",$datos);
$datos = str_replace("Ó","Ó",$datos);
$datos = str_replace("Ú","Ú",$datos);
$datos = str_replace("Ñ","Ñ",$datos);
return $datos;
}
?>