背景與動機(jī)
作為一名經(jīng)常瀏覽網(wǎng)頁的開發(fā)者,我使用 OneTab 插件來管理我的瀏覽器標(biāo)簽頁。OneTab 不僅幫我節(jié)省了內(nèi)存,還讓我能夠?qū)⑾嚓P(guān)的網(wǎng)頁鏈接組織在一起。然而,隨著時間推移,我積累了大量的 OneTab 歸檔,這些寶貴的資源卻難以被有效利用。
主要痛點(diǎn):
- 歷史收藏難以檢索
- 相關(guān)主題的鏈接分散在不同歸檔中
- 無法快速找到特定主題的所有相關(guān)資源
- 收藏的網(wǎng)頁內(nèi)容無法被有效利用
解決方案
我決定構(gòu)建一個基于 AI 的個人知識庫系統(tǒng),將 OneTab 中的網(wǎng)頁收藏轉(zhuǎn)化為可查詢的知識。整個方案分為以下幾個步驟:
1. 數(shù)據(jù)提取與處理
首先,我開發(fā)了一個 Python 腳本來處理 Edge 瀏覽器的收藏夾數(shù)據(jù):
# 從 Edge 收藏夾中提取 OneTab 鏈接
def get_onetab_urls(json_file):
with open(json_file, 'r', encoding='utf-8') as f:
bookmarks = json.load(f)
onetab_urls = []
for folder in bookmarks.get('收藏夾欄', []):
if folder.get('name') == 'onetab 歸檔':
for item in folder.get('children', []):
if item.get('type') == 'url':
onetab_urls.append({
'name': item['name'],
'url': item['url'],
'date_added': item['date_added']
})
return onetab_urls
2. 網(wǎng)頁內(nèi)容抓取
使用 requests 和 BeautifulSoup 庫來獲取和解析 OneTab 頁面內(nèi)容:
def parse_onetab_content(html_content):
soup = BeautifulSoup(html_content, 'html.parser')
groups = []
for group in soup.find_all(class_='tabGroup'):
group_title = group.find(class_='tabGroupLabel')
if not group_title:
continue
title = group_title.get_text(strip=True)
urls = []
for tab in group.find_all(class_='tab'):
link = tab.find(class_='tabLink')
if link:
url = link.get('href', '')
name = link.get_text(strip=True)
if url and name:
urls.append({
'name': name,
'url': url
})
if urls:
groups.append({
'title': title,
'urls': urls
})
return groups
3. 數(shù)據(jù)格式化
將處理后的數(shù)據(jù)轉(zhuǎn)換為結(jié)構(gòu)化的 Markdown 格式:
# OneTab - 20220217
添加時間: 2022-02-17 06:22:42
## 文檔化方法論
- Documentation Matters: Human-Centered AI System to Assist Data Science Code Documentation in Computational Notebooks | ACM Transactions on Computer-Human Interaction: https://dl.acm.org/doi/abs/10.1145/3489465
- A study of the documentation essential to software maintenance: https://dl.acm.org/doi/abs/10.1145/1085313.1085331
---
4. 知識庫構(gòu)建
使用 Dify 平臺構(gòu)建 AI 知識庫:
- 導(dǎo)入處理好的 Markdown 文件
- 配置知識庫參數(shù)
- 創(chuàng)建 AI Agent 并設(shè)置提示詞
最終效果
通過這個系統(tǒng),我現(xiàn)在可以:
- 快速檢索歷史收藏的網(wǎng)頁
- 按主題組織相關(guān)資源
- 通過自然語言查詢獲取相關(guān)信息
- 發(fā)現(xiàn)不同歸檔中的相關(guān)主題
例如,我可以這樣查詢:
-
"幫我找一下關(guān)于文檔化方法論的文章"
image-20250524163231-ty3lk34.png - "有哪些關(guān)于敏捷開發(fā)的資源?"
- "推薦一些關(guān)于 API 設(shè)計的最佳實(shí)踐"
技術(shù)亮點(diǎn)
- 自動化處理:整個數(shù)據(jù)提取和處理過程完全自動化
- 結(jié)構(gòu)化存儲:保持原有的主題分類結(jié)構(gòu)
- AI 增強(qiáng):利用 Dify 的 AI 能力實(shí)現(xiàn)智能檢索
- 可擴(kuò)展性:支持持續(xù)添加新的 OneTab 歸檔
總結(jié)
這個項(xiàng)目不僅解決了我的個人知識管理問題,還展示了如何將日常工具與 AI 技術(shù)結(jié)合,創(chuàng)造出更智能的工作方式。通過將散落的網(wǎng)頁收藏轉(zhuǎn)化為結(jié)構(gòu)化的知識庫,我能夠更有效地利用這些資源,提高工作效率。
