dtf1111 2015-09-06 15:15
浏览 63

通过php从html页面裁剪文本

Is it possible to access an existing text from a html page and use it in a new html page? I mean, for example, the music composer of Interstellar is Hans Zimmer, as written in this page https://en.wikipedia.org/wiki/Interstellar_%28film%29 when I inspect element, it is expanded from

<html class="client-js ve-not-available" lang="en" dir="ltr">
 <body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-Interstellar_film skin-vector action-view" s10754256041332868330="1" mp10754256041332868330="1" fghjktghndfgt="10754256041332868330" db10754256041332868330="1" dpx10754256041332868330="1" jhjlijpomuhn_9="1">
<div id="content" class="mw-body" role="main">
<div id="bodyContent" class="mw-body-content">
<div id="mw-content-text" class="mw-content-ltr" lang="en" dir="ltr">
<table class="infobox vevent" style="width:22em;font-size:90%;">
 <tbody>
  <tr>
   <td style="line-height:1.3em;">
    <a title="Hand Zimmer" href="/wiki/Hans_Zimmer"></a>
   </td>
  </tr>
 </tbody>
</table>

I know it can be accessed by jquery, but I need to access the text "Hans Zimmer" by php.

thanks for any kind of help

  • 写回答

5条回答 默认 最新

  • duanluan3651 2015-09-06 15:19
    关注

    Are you trying to get the HTML code for a page? If so, try using file_get_contents()

    <?php
    $page = file_get_contents('https://en.wikipedia.org/wiki/Interstellar_%28film%29');
    echo $page;
    ?>
    
    评论

报告相同问题?