在 Cocoa 中保存 Webarchive 而不使用图像
我有一个 WebView,我想将其保存为 WebArchive。我只想保存 HTML 部分而不是引用的图像。当我执行以下操作时,它似乎正在创建一个也嵌入图像的 WebArchive。
[[[[[sourceSignatureWebView mainFrame] dataSource] webArchive] data]
writeToFile:@"MyWebarchive.webarchive" atomically:YES];
除了我不想嵌入图像之外,Safari 似乎在显示文件时遇到了问题,并且在我想要的 HTML 部分周围显示了大量二进制乱码。我知道我可以使用 textutil 来创建文件,但如果可能的话我想在 Cocoa 中完成这一切。
有谁知道这是否可行?任何想法将不胜感激。谢谢!
I have a WebView that I want to save as a WebArchive. I just want to save the HTML part and not the referenced images. When I do the following, it appears to be creating a WebArchive with the images embedded as well.
[[[[[sourceSignatureWebView mainFrame] dataSource] webArchive] data]
writeToFile:@"MyWebarchive.webarchive" atomically:YES];
Besides the fact that I don't want to embed the images, Safari seems to have trouble displaying the file and is showing a lot of binary gibberish wrapped around the HTML part I want. I know I can use textutil to create the file, but if possible would like to do it all inside Cocoa.
Does anyone know if this is doable? Any ideas would be much appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的事情怎么样:
或者您实际上是在寻找 HTML 文件而不是 Web 存档?
How about something like this:
Or are you actually after an HTML file rather than web archive?