MetaProducts Offline Explorer使用簡易教程
by windtrace 20170419
最近想下載一個網站上的內容打包成chm文件,以便離線瀏覽,webzip太長時間不更新,而且只能機械的copy下html,不能自動修改其中鏈接指向,於是選擇了功能強大的Offline Explorer。使用中發現OE的project配置混亂晦澀,於是整理了此教程。
一、Project group
選擇new project后,會彈出Project Properties配置窗口。Project組包括6項內容:
l Address:設置項目名稱以及下載開始的地址(Starting web address),下載地址可以有多個。
l Level File Modification:對下載的文件進行初步過濾,如可以設置只下載系統更新過的文件。
l Passwords:網站需要密碼登陸時設置密碼。
l Url Macros:如果多個url有簡單規律(如僅是其中的某幾項遞增等),則在本項設置。
l Download Directory:下載文件存儲目錄。其中選項use unicode symbols in filename,應該是指文件名用unicode編碼,如utf-16,建議此項默認不選。
二、File Filters group
該組選項對下載的文件格式及其在服務器中的位置進行設置,配合下面的URL Filters可實現對下載內容的控制。
l Text:文本文件
l Images:圖片
l Videos:視頻
l Audios:音頻
l Archives:普通文件
l User Defined:主要是網頁顯示、功能相關的文件,如css、json等,此項一般要選擇,以免影響下載網頁的顯示。
l Other:其他文件
每項設置里面都有三方面內容:
1、location:用於控制下載文件在服務器中的位置,需要仔細選擇,以免下載混亂。
l Download using URL Filters Setting:與后面的URL Filters的設置保持一致。
l Download only from the starting server:只下載位於起始服務器(Starting server)的文件。如果前面的Starting web address 設置為http://zh.cppreference.com/w/,那么將只從zh.cppreference.com這個域名指定的服務器下載文件,en.cppreference.com中的文件會被排除。
l Download only from the starting direction:只下載位於服務器指定目錄及其子目錄的文件。如果前面的Starting web address 設置為http://zh.cppreference.com/w/,那么將只下載http://zh.cppreference.com/w/下的文件。注意:一些網頁的css、js等文件往往存放在其他目錄,如果選擇該項有可能導致這些文件無法下載而使頁面功能或顯示異常。
l Download from any website:下載任意網站上的文件,也就是對文件來源不加限制。
l Download only from the starting domain:只下載指定域名下的文件。此選項與上面第二項有所區別。OE官網沒有對server和domain進行說明,按一般理解,一個domain下可以有多個server,通常由域名的第一部分指定,如http://zh.cppreference.com和http://en.cppreference.com就是不同的server,但在同一個主域名cppreference.com下。
2、File size:通過文件的尺寸來控制下載與否。其Priority download選項,估計是用於表示在該項設置的條件與其他兩項沖突時,優先滿足該項條件。
3、Extensions:擴展名控制。
三、URL Filters
該組選項對目標文件的URL進行設置,以控制下載與否。
l URL Exclusions:不下載指定的url文件。可多個,支持通配符(后面會講)。可惜沒有inclusions選項,只能通過后面幾項勉強實現,搞得我焦頭爛額,也直接促成了本文的產生。比webzip差多了,如果程序員有心的話,后續版本中肯定會增加該功能。
l Protocols:協議選擇。
l Servers:服務器控制。可對服務器或域名進行控制(兩者區別見上面內容),如果是多個服務器,可通過關健字對服務器部分(即zh.cppreference.com這部分)進行篩選。官網的舉例:
Keyword |
Matches URLs |
Doesn’t match URLs |
zdnet.com |
http://www.zdnet.com/ http://hotfiles.zdnet.com http://zdnet.com.de |
http://www.zdnet.de |
www.zdnet |
http://www.zdnet.com/ http://my-www.zdnet.de/ |
http://hotfiles.zdnet.com http://zdnet.com.de |
w.zd |
http://www.zdnet.com/ http://www.zdnet.de/ |
http://hotfiles.zdnet.com http://zdnet.com.de |
www.*.com |
http://www.zdnet.com/ |
http://www.zdnet.de/ |
l Directions:目錄控制。對url中的目錄部分(即服務器后面的部分)進行控制。可多個,支持通配符(后面會講)。官網的舉例:
Keyword specified in the Included list |
Matches URLs |
Doesn’t match URLs |
somedir |
http://www.zdnet.com/somedir/file.htm http://files.com.de/somedirectory/ http://zdnet.com.uk/mysomedirs/ |
http://www.zdnet.de/someotherdir/ |
/path/dir |
http://www.zdnet.com/path/dir/file.htm http://www.zdnet.de/inside/path/directory/ |
http://hotfiles.zdnet.com/mypath/dir/file.gif http://zdnet.com.de/path/dir.txt |
^/mydir/$ |
http://www.zdnet.com/mydir/file.ext |
http://hotfiles.zdnet.com/mydir/path/file.txt http://zdnet.com.de/some/mydir/ |
http://www.s3.*/path |
http://www.s3.com/path/file.htm http://www.s3.jp/path/dir/image.jpgfile.htm |
http://www.zdnet.com/path/ |
l Filenames:文件名控制。可多個,支持通配符(后面會講)。官網的舉例:
Keyword |
Matches URLs |
Doesn't match URLs |
somefile |
http://www.zdnet.com/dir/somefile.htm http://files.com.de/file.asp?somefile=val |
http://www.zdnet.de/someotherfile |
default.htm |
http://www.server.com/dir/ http://www.other.com/default.htm |
http://www.server.com/file.html |
http://*.zdnet.*/path*/*.cgi |
http://www.zdnet.com/path/file.cgi http://www.zdnet.de/path/dir/other.cgi |
http://hotfiles.zdnet.com/mypath/dir/file.gif http://zdnet.com.de/path/dir.txt |
/*folder*/*.zip |
http://www.srv.com/dir/folder/other/file.zip http://www.other.uk/folder/archive.zip |
http://hotfiles.zdnet.com/folder/dir/file.gif http://zdnet.com.de/dir/file.zip |
link:Football |
Any link that has Football word in its text |
|
四、Content Filter
用於通過關健字對網頁中的內容篩選來控制下載與否。比較簡單,略過。
五、Advanced
其他設置,其中的Link Conversion比較有用,用於修改html的link標記:
l offline conversion:將所有下載的文件中的鏈接改為本地鏈接,如http://en.cppreference.com/w/cpp/file1.htm將被改為w/cpp/file1.htm,以便鏈接到本地文件。
l on-line conversion:將指向已下載文件的鏈接改為本地鏈接,指向未下載文件的鏈接修改為指向服務器文件(對於link標簽中的相對鏈接,會改為絕對鏈接)。
l no conversion:不對鏈接做特殊處理。
l Mixed:沒搞明白,估計是:同on-line conversion,但不修改指向未下載文件的鏈接。
六、通配符:來自官網
通配符 |
舉例 |
^ 匹配關健詞開始 |
^www.cnn 表示以 www.cnn為開始的字符串,如www.cnn.com |
$ 匹配關健詞結束 |
.htm$ 表示以 .htm.結束的字符串,如file1.htm |
[ ] 字符集合。匹配所包含的任意一個字符。 |
g[eo] 匹配 get 和got |
- 字符范圍,匹配指定范圍內的任意字符 |
[a-z] 可以匹配 'a' 到 'z' 范圍內的任意小寫字母字符 [0-9] 可以匹配所有數字 |
* 匹配一個或多個字符 |
^a*.gif$匹配所有以a開對,以.gif結尾的任意文件 |
七、參考
http://help.metaproducts.com/offline-explorer-enterprise/#setting-url-filters
時間倉促,錯誤難免,請見諒。