bugfix 爱企查 法人 地址等

This commit is contained in:
manchuwork
2025-12-12 03:12:17 +08:00
parent a1ac43d4e1
commit 2a99a38af5
7 changed files with 10037 additions and 10 deletions

View File

@@ -213,21 +213,47 @@
// 获取法定代表人
getLegalRepresentative() {
const legalElements = Array.from(
this.table.querySelectorAll("td")
).filter((td) => ToolUtils.cleanText(td.textContent) === "法定代表人");
if (legalElements.length > 0) {
const valueCell = legalElements[0].nextElementSibling;
if (valueCell && valueCell.classList.contains("image-text-content")) {
const nameElement = valueCell.querySelector(".person-name-warp a");
if (nameElement) {
return ToolUtils.cleanText(nameElement.textContent);
// First check for 经营者 (operator) which is used for individual businesses
const operatorElements = Array.from(
this.table.querySelectorAll("td")
).filter((td) => (ToolUtils.cleanText(td.textContent) === "经营者") ||
ToolUtils.cleanText(td.textContent) === "执行事务合伙人" ||
ToolUtils.cleanText(td.textContent) === "负责人" ||
ToolUtils.cleanText(td.textContent) === "法定代表人"
);
if (operatorElements.length > 0) {
const valueCell = operatorElements[0].nextElementSibling;
if (valueCell) {
// Check if it has the image-text-content structure
if (valueCell.classList.contains("image-text-content")) {
const nameElement = valueCell.querySelector(".person-name-warp a");
if (nameElement) {
return ToolUtils.cleanText(nameElement.textContent);
}
return ToolUtils.cleanText(valueCell.textContent);
}
// Regular structure
return ToolUtils.cleanText(valueCell.textContent);
}
}
// const legalElements = Array.from(
// this.table.querySelectorAll("td")
// ).filter((td) => ToolUtils.cleanText(td.textContent) === "法定代表人");
// if (legalElements.length > 0) {
// const valueCell = legalElements[0].nextElementSibling;
// if (valueCell && valueCell.classList.contains("image-text-content")) {
// const nameElement = valueCell.querySelector(".person-name-warp a");
// if (nameElement) {
// return ToolUtils.cleanText(nameElement.textContent);
// }
// return ToolUtils.cleanText(valueCell.textContent);
// }
// }
// 备用查找方式
const titleElements = Array.from(
this.table.querySelectorAll("td")
).filter((td) => td.textContent.includes("法定代表人"));
@@ -388,6 +414,20 @@
return match ? match[0] : null;
}
// 尝试查找其他可能包含员工数的字段
const employeeElements = Array.from(
this.table.querySelectorAll("td")
).filter((td) =>
td.textContent.includes("人员规模") ||
td.textContent.includes("员工人数")
);
if (employeeElements.length > 0 && employeeElements[0].nextElementSibling) {
const valueCell = employeeElements[0].nextElementSibling;
const rawText = valueCell.textContent.replace(/[\r\n\t]/g, "").trim();
return rawText;
}
return null;
}
@@ -421,6 +461,12 @@
}
}
// 如果没有核准日期,尝试使用成立日期作为替代
const establishmentDate = this.getOptimizedValue("成立日期");
if (establishmentDate && /^\d{4}-\d{2}-\d{2}$/.test(establishmentDate)) {
return establishmentDate;
}
return null;
}
@@ -761,7 +807,36 @@ class NationalCreditParser {
// 获取住所/注册地址
getRegisteredAddress() {
return this.getOptimizedValue("住所");
// return this.getOptimizedValue("住所");
// 主要查找方式
const address = this.getOptimizedValue("注册地址");
if (address) {
return address;
}
// 备用查找方式
const alternativeElements = Array.from(
this.table.querySelectorAll("td")
).filter((td) =>
ToolUtils.cleanText(td.textContent).includes("住所") ||
ToolUtils.cleanText(td.textContent).includes("营业地址") ||
ToolUtils.cleanText(td.textContent).includes("办公地址")
);
if (alternativeElements.length > 0 && alternativeElements[0].nextElementSibling) {
const valueCell = alternativeElements[0].nextElementSibling;
const valueElement =
valueCell.querySelector(".enter-bg-ele") ||
valueCell.querySelector(".addr-enter-bg-ele") ||
valueCell;
const addressText = ToolUtils.cleanText(valueElement.textContent);
if (addressText) {
return addressText;
}
}
return null;
}
// 获取经营范围