iOS 通过 UIWebView 访问 Safari Reader 功能 [英] iOS access to Safari Reader feature through UIWebView

查看:23
本文介绍了iOS 通过 UIWebView 访问 Safari Reader 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iOS 4.3 &想知道是否有任何方法可以访问 的东西.但我不知道如何通过 UIWebView 使用它.还有一些网站Safari的Reader接电话不开启Reader"功能,可能是信心不足?

解决方案

实际上,阅读器按钮会在解析 HTML 页面的地方进行一些分析,然后看到要解析的清晰 body 标签.如果该插件能够提取确切的正文,它将启用阅读器按钮(我对可读性源代码的理解).现在要为 webview 实现相同的功能,您只需在代码中嵌入 java 脚本(该 java 脚本已经在可读性源代码中可用),然后您就可以达到相同的效果.

但我怀疑苹果的未来计划也是如此.因为他们不能让其他任何人来做这个内容提取,同时与 iCloud 相关的巨大商机和可读性相结合.

如果您愿意,您可以简单地从 UIWebView 中提取 HTML,然后提取正文并将其用于您的目的.提取它并不是一门火箭般的科学.

从分析的角度来看,随便有10个HTML页面启用了Reader按钮,你会看到核心内容只属于body,其余的add、header、footer是分开的.

我相信现在是重新发明我们使用的网络内容的时候了,这是这样做的完美例子.

I am using iOS 4.3 & was wondering if there is any way that I can access the Safari's "Reader" feature through which webpages are removed of ads & other riff raff & the content takes the center stage.

If one opens any article in Safari (on say Wikipedia website), then a "Reader" button appears on the URL bar. Clicking on it presents a new window presenting the content beautifully.

How can I leverage this this functionality in iOS through UIWebView ?

PS: I know there is something called Readability Project. But I have no idea how to use this through UIWebView. Also for some websites Safari's Reader takes a call not to enable "Reader" feature, maybe it has no sufficient confidence?

解决方案

Actually reader button do a bit of analysis where it parse the HTML Page and then it sees a clear body tag to parse. If that plugin is able to extract the exact body it will enable the reader button (My understanding from the readability source code). Now to implement the same for webview you just need to embed java script in your code (this java script is already available in the readability source code) and then you can achieve the same effect.

But I suspect the future plan from apple for the same. Because they can not just let anyone else do this content extraction with the huge business opportunity associated with iCloud with the combination of readability.

If you want you can simple extract the HTML from UIWebView and then extract the body and use it for your purpose. It's not a very rocket science to extract.

For analysis point of view, just have randomly some 10 HTML pages with Reader button enabled, you will see the core cotent belongs to body only and rest of the add, header, footer are separated.

I believe this is the time to re-invent the web content we use, and this is the perfect example of doing the same.

这篇关于iOS 通过 UIWebView 访问 Safari Reader 功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆