https://feather.wiki/ <--下載
download HTML file (press Download Version 1.2.1 Now)
- 這是單一個 HTML, 可以存在任何地方,然後用瀏覽器(例如firefox)打開
- 它是網頁型態,以文字、圖片方式呈現
- 不依賴任何編輯軟體或作業系統(瀏覽器要能支援javascript)
- 有基本的編輯功能,像是粗體、斜體、低線、刪除線、標題大字、序號編列、網路連結、插入圖檔等。
壞處:沒有自動存檔功能,按下載後會存在瀏覽器下載檔案的地方,並且檔名會加上數字順序,因此變成很多個檔。
解決方法:利用python watchdog來把下載的檔案搬去覆蓋原來的檔案,就不會有很多檔案了。
用到的主要有:
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class Watcher:
裡面定義 WHERE_TO_WATCH =
class Handler(FileSystemEventHandler):
裡面定義如果有新檔產生
def on_created(event):
if event.event_type == 'created'
就透過 system() 去把它搬到原檔案放的地方,覆蓋過去。
from time import sleep
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from os import path, popen, environ, system
from sys import exit
GHome = environ['HOME']
MyFile1 = 'NB1.html'
MyFile2 = 'NB2.html'
class Watcher:
WHERE_TO_WATCH = GHome + '/Downloads'
def __init__(self):
self.observer = Observer()
def run(self):
event_handler = Handler()
self.observer.schedule(event_handler, self.WHERE_TO_WATCH, recursive=True)
self.observer.start()
try:
while True:
sleep(5)
except KeyboardInterrupt:
self.observer.stop()
print("Exit")
exit(1)
self.observer.join()
class Handler(FileSystemEventHandler):
@staticmethod
def on_created(event):
if event.is_directory:
return None
elif event.event_type == 'created':
if MyFile1 in event.src_path or MyFile2 in event.src_path:
F = event.src_path
Fsize = path.getsize(F)
sleep(0.07)
system('mv %s %s'%(F,GHome))
Tstamp = popen('date +\'%m%d_%H%M%S\'').readline().strip()
print(Tstamp,Fsize,F)
if __name__ == '__main__':
w = Watcher()
w.run()
沒有留言:
張貼留言