Actualizar robot.js
This commit is contained in:
33
robot.js
33
robot.js
@@ -70,22 +70,23 @@ async function runMultiasistencia(ownerId, user, pass) {
|
||||
if (descHeader && descHeader.nextElementSibling) rawDesc = clean(descHeader.nextElementSibling.innerText);
|
||||
const idxDate = rawDesc.search(/\b\d{2}\/\d{2}\/\d{4}\b/);
|
||||
const cleanDesc = idxDate !== -1 ? rawDesc.substring(0, idxDate).trim() : rawDesc;
|
||||
const rawCPField = findByCab("Distrito Postal") || "";
|
||||
const cpMatch = rawCPField.match(/\b\d{5}\b/);
|
||||
const cpOnly = cpMatch ? cpMatch[0] : "";
|
||||
const popOnly = rawCPField.replace(cpOnly, '').replace('-', '').trim();
|
||||
const phoneMatch = body.match(/[6789]\d{8}/);
|
||||
return {
|
||||
"Expediente": findByCab("Número Reparación") || "",
|
||||
"Nombre Cliente": findByCab("Nombre Cliente") || "",
|
||||
"Dirección": findByCab("Dirección") || "",
|
||||
"Población": popOnly,
|
||||
"Código Postal": cpOnly,
|
||||
"Compañía": "MULTI - " + (findByCab("Procedencia") || "MULTIASISTENCIA"),
|
||||
"Descripción": cleanDesc,
|
||||
"Teléfono": phoneMatch ? phoneMatch[0] : "",
|
||||
"Urgente": findByCab("Urgente") || "No"
|
||||
};
|
||||
// ... (dentro de runMultiasistencia - evaluate)
|
||||
const rawCPField = findByCab("Distrito Postal") || "";
|
||||
const cpMatch = rawCPField.match(/\b\d{5}\b/);
|
||||
const cpOnly = cpMatch ? cpMatch[0] : "";
|
||||
const popOnly = rawCPField.replace(cpOnly, '').replace('-', '').trim();
|
||||
|
||||
return {
|
||||
"Expediente": findByCab("Número Reparación") || "",
|
||||
"Nombre Cliente": findByCab("Nombre Cliente") || "",
|
||||
"Dirección": findByCab("Dirección") || "",
|
||||
"Población": popOnly,
|
||||
"Código Postal": cpOnly, // CAMPO RECUPERADO
|
||||
"Compañía": "MULTI - " + (findByCab("Procedencia") || "MULTIASISTENCIA"),
|
||||
"Descripción": cleanDesc,
|
||||
"Teléfono": phoneMatch ? phoneMatch[0] : "",
|
||||
"Urgente": findByCab("Urgente") || "No"
|
||||
};
|
||||
});
|
||||
if (scrapData && scrapData['Nombre Cliente']) break;
|
||||
} catch (e) { continue; }
|
||||
|
||||
Reference in New Issue
Block a user