Cross-Platform Way of Creating Safari Webarchives

前端 未结 5 751
一向
一向 2020-12-17 21:58

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 thi

相关标签:
5条回答
  • 2020-12-17 22:16

    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…

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-17 22:27

    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.

    0 讨论(0)
  • 2020-12-17 22:37

    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.

    0 讨论(0)
  • 2020-12-17 22:39

    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

    0 讨论(0)
提交回复
热议问题