iOS access to Safari Reader feature through UIWebView

前端 未结 6 672
梦如初夏
梦如初夏 2020-12-23 18:19

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

6条回答
  •  生来不讨喜
    2020-12-23 18:51

    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.

提交回复
热议问题