您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Export patent information to CSV format
当前为
// ==UserScript== // @name Export Patent Info // @namespace http://your.site.com // @version 0.1 // @description Export patent information to CSV format // @author Your Name // @match *://*.cponline.cnipa.gov.cn/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 创建导出按钮 const exportButton = document.createElement('button'); exportButton.textContent = '导出专利信息'; exportButton.style.position = 'fixed'; exportButton.style.top = '120px'; exportButton.style.right = '20px'; exportButton.style.zIndex = '9999'; exportButton.addEventListener('click', function() { // 创建一个数组来保存提取的信息 let patentsData = []; // 遍历每个专利信息元素 document.querySelectorAll('.table_info').forEach(function(patent) { // 提取元素内部的各项信息 const spans = patent.querySelectorAll('span'); let Application_OR_Patent_Number = patent.querySelector('.hover_active').textContent.trim(); const title = `"${patent.querySelector('span span').textContent.trim()}"`; let Applicant = `"${spans[6].textContent.trim().replace("申请人:", "")}"`; let ApplicationDate = `"${spans[10].textContent.trim().replace("申请日:", "")}"`; let AuthorizationAnnouncementNumber = `"${spans[14].textContent.trim().replace("授权公告号:", "")}"`; let legalStatus = `"${spans[16].textContent.trim().replace("法律状态:", "")}"`; let CaseStatus = `"${spans[18].textContent.trim().replace("案件状态:", "")}"`; let AuthorizationAnnouncementDate = `"${spans[20].textContent.trim().replace("授权公告日:", "")}"`; // 处理申请号_专利号字段为纯文本格式 // 如果申请号_专利号是数字,则转换为文本 if (!isNaN(Application_OR_Patent_Number.replace(/[^0-9]/g, ''))) { Application_OR_Patent_Number = `${Application_OR_Patent_Number}`; } // 将提取的信息添加到数组中 patentsData.push({ '申请号_专利号': Application_OR_Patent_Number, '发明名称': title, '申请人': Applicant, '申请日': ApplicationDate, '授权公告号': AuthorizationAnnouncementNumber, '法律状态': legalStatus, '案件状态': CaseStatus, '授权公告日': AuthorizationAnnouncementDate }); }); // 导出数据到 Excel 表格 if (patentsData.length > 0) { exportToExcel(patentsData); } else { console.error('没有可导出的专利信息!'); } }); document.body.appendChild(exportButton); // 导出数据到 Excel 表格 function exportToExcel(data) { const header = Object.keys(data[0]); const rows = data.map(obj => header.map(key => obj[key])); const csvContent = header.join(',') + '\n' + rows.map(row => row.join(',')).join('\n'); const blob = new Blob([new Uint8Array([0xEF, 0xBB, 0xBF]), csvContent], { type: 'text/csv;charset=utf-8' }); const url = URL.createObjectURL(blob); // 使用浏览器的下载功能下载 CSV 文件 const a = document.createElement('a'); a.href = url; a.download = 'patent_info.csv'; a.click(); } })();