增加天眼查
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// @author You
|
||||
// @match https://www.qcc.com/firm/*
|
||||
// @match https://aiqicha.baidu.com/company_detail_*
|
||||
// @match https://www.tianyancha.com/company/*
|
||||
// @match https://shiming.gsxt.gov.cn/*
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
@@ -863,7 +864,209 @@ class NationalCreditParser {
|
||||
}
|
||||
}
|
||||
// end国家企业信用信息公示系统解析类
|
||||
// 天眼查解析类
|
||||
// 天眼查解析类
|
||||
class TianYanChaParser {
|
||||
constructor() {
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
// 初始化容器
|
||||
initContainer() {
|
||||
// 使用正确的容器选择器
|
||||
this.container = document.querySelector(".index_tableBox__ZadJW");
|
||||
if (!this.container) {
|
||||
alert("未找到企业信息容器");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 获取法定代表人
|
||||
getLegalRepresentative() {
|
||||
const legalElement = document.querySelector(".index_legal-representative__Kfdqv a.link-click");
|
||||
if (legalElement) {
|
||||
return ToolUtils.cleanText(legalElement.textContent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 从表格中获取值
|
||||
getValueByLabel(label,includeOnlyTextNode=false) {
|
||||
const rows = Array.from(document.querySelectorAll("tr"));
|
||||
for (const row of rows) {
|
||||
const cells = Array.from(row.children);
|
||||
for (let i = 0; i < cells.length; i++) {
|
||||
const cellText = ToolUtils.cleanText(cells[i].textContent);
|
||||
if (cellText.includes(label)) {
|
||||
// 查找下一个单元格作为值
|
||||
const nextCell = cells[i + 1];
|
||||
if (nextCell) {
|
||||
if(includeOnlyTextNode){
|
||||
// Extract only direct text content, excluding nested divs
|
||||
let directText = '';
|
||||
for (const node of nextCell.childNodes) {
|
||||
// directText+='node text:'+node.textContent+', type:'+ node.nodeType+'\n';
|
||||
// console.log('node:',node,' node type:',node.nodeType," node.textContent:",node.textContent);
|
||||
// Only include text nodes and exclude elements with classes
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
directText += node.textContent;
|
||||
}
|
||||
}
|
||||
return ToolUtils.cleanText(directText);
|
||||
}else{
|
||||
// 处理包含复制按钮的特殊结构
|
||||
const copyBox = nextCell.querySelector(".index_copy-box__7b6Aq");
|
||||
if (copyBox) {
|
||||
const copyText = copyBox.querySelector(".index_copy-text__ri7W6");
|
||||
if (copyText) {
|
||||
return ToolUtils.cleanText(copyText.textContent);
|
||||
}
|
||||
}
|
||||
return ToolUtils.cleanText(nextCell.textContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取统一社会信用代码
|
||||
getUnifiedSocialCreditCode() {
|
||||
return this.getValueByLabel("统一社会信用代码");
|
||||
}
|
||||
|
||||
// 获取企业名称
|
||||
getCompanyName() {
|
||||
const nameElement = document.querySelector("h1.index_company-name__LqKlo .index_name__dz4jY");
|
||||
if (nameElement) {
|
||||
return ToolUtils.cleanText(nameElement.textContent);
|
||||
}
|
||||
return this.getValueByLabel("企业名称");
|
||||
}
|
||||
|
||||
// 获取注册资本
|
||||
getRegisteredCapital() {
|
||||
return this.getValueByLabel("注册资本");
|
||||
}
|
||||
|
||||
// 获取成立日期
|
||||
getEstablishmentDate() {
|
||||
return this.getValueByLabel("成立日期");
|
||||
}
|
||||
|
||||
// 获取经营状态
|
||||
getBusinessStatus() {
|
||||
return this.getValueByLabel("登记状态") || this.getValueByLabel("经营状态");
|
||||
}
|
||||
|
||||
// 获取工商注册号
|
||||
getBusinessRegistrationNo() {
|
||||
return this.getValueByLabel("工商注册号");
|
||||
}
|
||||
|
||||
// 获取组织机构代码
|
||||
getOrganizationCode() {
|
||||
return this.getValueByLabel("组织机构代码");
|
||||
}
|
||||
|
||||
// 获取纳税人识别号
|
||||
getTaxpayerId() {
|
||||
return this.getValueByLabel("纳税人识别号");
|
||||
}
|
||||
|
||||
// 获取核准日期
|
||||
getApprovalDate() {
|
||||
return this.getValueByLabel("核准日期");
|
||||
}
|
||||
|
||||
// 获取登记机关
|
||||
getRegistrationAuthority() {
|
||||
return this.getValueByLabel("登记机关");
|
||||
}
|
||||
|
||||
// 获取注册地址
|
||||
getRegisteredAddress() {
|
||||
return this.getValueByLabel("注册地址");
|
||||
}
|
||||
|
||||
// 获取经营范围
|
||||
getBusinessScope() {
|
||||
return this.getValueByLabel("经营范围");
|
||||
}
|
||||
|
||||
// 获取实缴资本
|
||||
getActualCapital() {
|
||||
return this.getValueByLabel("实缴资本");
|
||||
}
|
||||
|
||||
// 获取企业类型
|
||||
getEnterpriseType() {
|
||||
return this.getValueByLabel("企业类型");
|
||||
}
|
||||
|
||||
// 获取参保人数
|
||||
getInsuranceNumber() {
|
||||
const result = this.getValueByLabel("参保人数",true);
|
||||
if (result) {
|
||||
// Extract only the first number from the beginning of the string
|
||||
// This handles cases where there are additional elements like "2024年报" after the number
|
||||
const match = result.match(/^(\d+)/);
|
||||
if (match) {
|
||||
return match[1] + "人";
|
||||
}
|
||||
// Fallback to the original regex pattern
|
||||
const fallbackMatch = result.match(/(\d+)人/);
|
||||
return fallbackMatch ? `${fallbackMatch[1]}人` : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取联系电话
|
||||
getPhoneNumber() {
|
||||
// 查找电话信息
|
||||
const phoneElements = document.querySelectorAll(".index_detail-info-item__oAOqL");
|
||||
for (const element of phoneElements) {
|
||||
const labelText = ToolUtils.cleanText(element.textContent);
|
||||
if (labelText.includes("电话")) {
|
||||
const phoneSpan = element.querySelector(".link-hover-click");
|
||||
if (phoneSpan) {
|
||||
return ToolUtils.cleanText(phoneSpan.textContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 解析公司信息主方法
|
||||
parseCompanyInfo() {
|
||||
if (!this.initContainer()) return;
|
||||
|
||||
const companyData = {
|
||||
企业名称: this.getCompanyName(),
|
||||
统一社会信用代码: this.getUnifiedSocialCreditCode(),
|
||||
法定代表人: this.getLegalRepresentative(),
|
||||
电话: this.getPhoneNumber(),
|
||||
经营状态: this.getBusinessStatus(),
|
||||
成立日期: this.getEstablishmentDate(),
|
||||
注册资本: this.getRegisteredCapital(),
|
||||
实缴资本: this.getActualCapital(),
|
||||
企业类型: this.getEnterpriseType(),
|
||||
工商注册号: this.getBusinessRegistrationNo(),
|
||||
组织机构代码: this.getOrganizationCode(),
|
||||
纳税人识别号: this.getTaxpayerId(),
|
||||
核准日期: this.getApprovalDate(),
|
||||
登记机关: this.getRegistrationAuthority(),
|
||||
注册地址: this.getRegisteredAddress(),
|
||||
经营范围: this.getBusinessScope(),
|
||||
参保人数: this.getInsuranceNumber(),
|
||||
};
|
||||
|
||||
ToolUtils.showResult(companyData);
|
||||
}
|
||||
}
|
||||
// end 天眼查解析类
|
||||
|
||||
// 创建按钮容器
|
||||
function createButtonContainer() {
|
||||
@@ -997,7 +1200,9 @@ class NationalCreditParser {
|
||||
parser = new AiQiChaParser();
|
||||
} else if (window.location.host.includes("qcc.com")) {
|
||||
parser = new QCCParser();
|
||||
} else if (window.location.host.includes("gsxt.gov.cn")) {
|
||||
} else if (window.location.host.includes("tianyancha.com")) {
|
||||
parser = new TianYanChaParser();
|
||||
} else if (window.location.host.includes("gsxt.gov.cn")) {
|
||||
parser = new NationalCreditParser();
|
||||
} else {
|
||||
alert("不支持的网站");
|
||||
|
||||
Reference in New Issue
Block a user