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

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

问题描述

我正在使用iOS 4.3&我想知道是否有任何办法可以访问的内容。但我不知道如何通过 UIWebView 来使用它。另外对于某些网站,Safari的读者接听电话不启用读者功能,也许它没有足够的信心?

解决方案

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



但我怀疑苹果的未来计划是一样的。因为他们不能让其他任何人通过与iCloud相关的巨大商机与可读性相结合来进行内容提取。



如果你想要,你可以简单地提取HTML从UIWebView然后提取正文并将其用于您的目的。提取它并不是一个非常火箭的科学。



从分析的角度来看,只要随机启用阅读器按钮就会有10个HTML页面,你会看到核心的cotent属于只有正文和其余的添加,页眉,页脚是分开的。



我认为现在是重新发明我们使用的网页内容的时候了,这是完美的做同样的例子。


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天全站免登陆