50cc7cb1cf
- Import 789,853 legal articles from LawRefBook/Laws - Add 19,712 laws including national and regional regulations - Filter 1,370 expired laws - Create vectorization scripts and backup tools - Add law update monitoring mechanism - Generate comprehensive documentation Database: PostgreSQL with GIN index for full-text search Vectorization: 100% complete with LegalSemanticMatcher Performance: 7x improvement in semantic search Co-Authored-By: Claude <noreply@anthropic.com>
98 lines
3.5 KiB
JavaScript
98 lines
3.5 KiB
JavaScript
// ========================================
|
|
// 在国家法律法规数据库网站使用的辅助脚本
|
|
// 使用方法:
|
|
// 1. 打开 https://flk.npc.gov.cn
|
|
// 2. 按 F12 打开开发者工具
|
|
// 3. 切换到 Console 标签
|
|
// 4. 复制粘贴以下代码运行
|
|
// ========================================
|
|
|
|
// 方法1:从搜索结果页面提取所有法律的bbbs
|
|
// 在搜索结果页面运行此函数
|
|
function extractBbbsFromSearchResults() {
|
|
const results = [];
|
|
|
|
// 尝试从页面元素提取
|
|
document.querySelectorAll('a[href*="detail"]').forEach(link => {
|
|
const href = link.getAttribute('href') || '';
|
|
const match = href.match(/[?&]id=([a-f0-9]{32})/);
|
|
if (match) {
|
|
results.push({
|
|
title: link.textContent.trim(),
|
|
bbbs: match[1],
|
|
url: href
|
|
});
|
|
}
|
|
});
|
|
|
|
console.log('找到的法律:', results);
|
|
console.table(results);
|
|
return results;
|
|
}
|
|
|
|
// 方法2:从API响应中提取(需要监听网络请求)
|
|
// 在 Network 标签中找到包含 bbbs 的响应,右键复制响应内容
|
|
// 然后运行此函数解析
|
|
function parseApiResponse(responseText) {
|
|
try {
|
|
const data = JSON.parse(responseText);
|
|
if (data.data) {
|
|
const items = Array.isArray(data.data) ? data.data :
|
|
data.data.rows ? data.data.rows :
|
|
data.data.content ? data.data.content.children : [];
|
|
|
|
const results = items.map(item => ({
|
|
title: item.title,
|
|
bbbs: item.bbbs,
|
|
type: item.flxz
|
|
}));
|
|
|
|
console.log('解析结果:', results);
|
|
console.table(results);
|
|
return results;
|
|
}
|
|
} catch (e) {
|
|
console.error('解析失败:', e);
|
|
}
|
|
}
|
|
|
|
// 方法3:监听网络请求并自动收集bbbs
|
|
let collectedBbbs = [];
|
|
const originalOpen = XMLHttpRequest.prototype.open;
|
|
XMLHttpRequest.prototype.open = function(method, url) {
|
|
this.addEventListener('load', function() {
|
|
if (url.includes('flfgDetails') || url.includes('search/list')) {
|
|
try {
|
|
const data = JSON.parse(this.responseText);
|
|
if (data.data) {
|
|
const items = data.data.rows || [data.data];
|
|
items.forEach(item => {
|
|
if (item.bbbs && item.title) {
|
|
collectedBbbs.push({
|
|
title: item.title,
|
|
bbbs: item.bbbs,
|
|
type: item.flxz
|
|
});
|
|
}
|
|
});
|
|
console.log('已收集 ' + collectedBbbs.length + ' 条法律:');
|
|
console.table(collectedBbbs);
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
});
|
|
return originalOpen.apply(this, arguments);
|
|
};
|
|
|
|
console.log('脚本已加载!现在开始搜索法律,结果会自动收集。');
|
|
console.log('收集完成后运行: console.table(collectedBbbs) 查看结果');
|
|
console.log('导出为JSON: copy(collectedBbbs) 然后粘贴到文本编辑器');
|
|
|
|
// ========================================
|
|
// 使用说明
|
|
// ========================================
|
|
// 1. 运行此脚本后,在网站上搜索法律
|
|
// 2. 点击进入详情页,bbbs会被自动收集
|
|
// 3. 搜索多部法律后,运行 console.table(collectedBbbs) 查看所有收集的bbbs
|
|
// 4. 运行 copy(collectedBbbs) 复制结果,然后粘贴保存
|