PHP - how to get main HTML content like Reader Mode in Firefox

前端 未结 5 2047
无人共我
无人共我 2021-02-11 06:33

in android Firefox app and safari iPad we can read only main content by \"Reader Mode\". read more... How to recognize only main content in HTML with PHP?

I need to dete

5条回答
  •  不要未来只要你来
    2021-02-11 06:57

    There is no such built-in function in PHP. I am afraid will have to parse and analyse the HTML document yourself. You will probably need to use some XML parser, the SimpleXML library is a good candidate.

    I am not familiar with the "Reader mode" feature you are referring to, but a good starting point would probably be removing all contents. The actual "cleanning" algorithm it uses is certainly not trivial at all, and it seems it is actually implemented as a call to a third party, closed soure, service in Javascript.

提交回复
热议问题