#!/usr/bin/env python
"""Print urls from given firefox profile.
Usage: firefox-urls <profile-dir>
Example: firefox-urls ~/.mozilla/firefox/4dfb4drtz.default
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Places/Database
"""
import os
import sqlite3
import sys
try:
db = sqlite3.connect(os.path.join(sys.argv[1], 'places.sqlite'))
urls = db.execute('select url from moz_places')
except (IndexError, sqlite3.OperationalError):
sys.exit(__doc__) # print usage and exit
for [url] in urls:
print(url)
moz_historyvisits该表包含对页面的每次访问(日期、引荐来源网址和指向moz_places具有相应 URL 的表的链接)。例如,要显示页面地址和它们今天被访问的本地时间(从当天的 UTC 开始):
#!/usr/bin/env python3
"""Print urls of visited pages [UTC] today from the default firefox profile.
Usage: firefox-day-history
"""
import datetime as DT
import os
import sqlite3
from pathlib import Path
firefox_dir = Path('~/.mozilla/firefox/').expanduser()
db_path = next(firefox_dir.glob('*.default/places.sqlite'))
db = sqlite3.connect(os.fspath(db_path))
for visit_date, url in db.execute(
"select h.visit_date, p.url"
" from moz_historyvisits as h, moz_places as p"
" where date(h.visit_date/1000000, 'unixepoch') == date('now')"
" and p.id == h.place_id order by h.visit_date"):
print(DT.datetime.fromtimestamp(visit_date//1000000).time(), url)
要打印 firefox 已知的链接,只需从相应的firefox 配置文件中读取
places.sqlite
数据库:moz_historyvisits
该表包含对页面的每次访问(日期、引荐来源网址和指向moz_places
具有相应 URL 的表的链接)。例如,要显示页面地址和它们今天被访问的本地时间(从当天的 UTC 开始):你可以试试scapy。
下面是一个嗅探控制台的小例子:
此示例可能不适用于 HTTPS 站点。