Cross-Platform Way of Creating Safari Webarchives

笑着哭i 提交于 2019-11-28 00:03:52

问题


I've been searching around and haven't found any reference to tools that can create Safari's webarchive format.

Does anyone have pointers to code for creating this format, or at least a format reference documentation?

Ideally I'd like to build a tool that takes a directory and splits out a webarchive, for loading into a iPhone.


回答1:


To expand on what Ben said: CFLite (the cross-platform open-source subset of Core Foundation) ships with a plist parser. If you can link against that, it should be quite simple to work with .webarchive files, which are simply property lists that concatenate all files (HTML, CSS, etc.) into one.

There are other libraries as well, such as Mac-PropertyList on CPAN for Perl.




回答2:


I believe the format for .webarchives is officially undocumented, but it's just a plist. You can open it in the Property List Editor and examine its contents. Shouldn't be to hard to replicate most, if not all, of what's in there.




回答3:


Tried textutil, but that only uses the Cocoa text system and as such fails at css, js and such.

There's a nice GitHub project: https://github.com/takebayashi/STWebArchiver

It uses Webkit to write .webarchive files. Needs some customization for your needs…




回答4:


Webarchive creation is part of Webkit luckily, as such you can use the following for working with them on the Mac:

http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/WebKit/Classes/WebArchive_Class/Reference/Reference.html

Or, use this sourcecode to understand the format in usage:

http://trac.webkit.org/browser/trunk/WebKit/mac/WebView/WebArchive.mm




回答5:


It's not cross-plattform, but on the Mac

textutil -convert webarchive whatever.html

does the job. Not sure whether you can easily include images etc. though.



来源:https://stackoverflow.com/questions/219530/cross-platform-way-of-creating-safari-webarchives

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!