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

前端 未结 5 1985
无人共我
无人共我 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 07:13

    this is to display the whole content if you want more information about this just search in Google about regular expression and how to get value between tags in a html file i will tell you why with a demo :)

    first off, when you use function file get contents you will get the file with html code but the server or browser will display it like a page look at this code,

    $html = file_get_contents('http://coder-dz.com');
    preg_match_all('/
  • (.*?)<\/li>/s', $html, $matches); foreach($matches[1] as $mytitle) { echo $mytitle."
    "; }
  • well what i did here? i get the content of my website is word press i get titles because title they are in a tag of HTML li after that i used regular expression to get the values between this tags.

    i hope you get my point because I’m not at English, if you have any question feel free to ask me

提交回复
热议问题