PHP剥离动态内容

时间:2016-01-05 05:41:29

标签: php regex preg-match-all strip

我有一个网址,我想抓住部分返回文字,但我不知道该怎么做。这是我的卷发目前正在回归:

<div class="bibleReadingsWrapper">
   <h4>Responsorial Psalm <a href="/bible/psalms/2:7">Ps 2:7bc-8, 10-12a</a></h4>
   <div class="poetry"> R. (8ab) <strong>I will give you all the nations for an inheritance.</strong><br>
      The LORD said to me, “You are my Son;<br>
      this day I have begotten you.<br>
      Ask of me and I will give you<br>
      the nations for an inheritance<br>
      and the ends of the earth for your possession.”<br>
      R. <strong>I will give you all the nations for an inheritance.</strong><br>
      And now, O kings, give heed;<br>
      take warning, you rulers of the earth.<br>
      Serve the LORD with fear, and rejoice before him;<br>
      with trembling rejoice.<br>
      R. <strong>I will give you all the nations for an inheritance.</strong><br>
      <h4>Alleluia <a href="/bible/matthew/4:23">See Mt 4:23</a></h4>
      R. <strong>Alleluia, alleluia.</strong><br>
      Jesus proclaimed the Gospel of the kingdom<br>
      and cured every disease among the people.<br>
      R. <strong>Alleluia, alleluia.</strong><br>
   </div>
</div>
<div class="bibleReadingsWrapper">
   <h4>Gospel <a href="/bible/matthew/4:12">Mt 4:12-17, 23-25</a></h4>
   <div class="poetry"> When Jesus heard that John had been arrested,<br>
      he withdrew to Galilee. <br>
      He left Nazareth and went to live in Capernaum by the sea,<br>
      in the region of Zebulun and Naphtali,<br>
      that what had been said through Isaiah the prophet <br>
      might be fulfilled:<br>
      <br>
      <em>Land of Zebulun and land of Naphtali,<br>
      the way to the sea, beyond the Jordan,<br>
      Galilee of the Gentiles,<br>
      the people who sit in darkness<br>
      have seen a great light,<br>
      on those dwelling in a land overshadowed by death<br>
      light has arisen.</em><br>
      <br>
      From that time on, Jesus began to preach and say,<br>
      “Repent, for the Kingdom of heaven is at hand.”<br>
      <br>
      He went around all of Galilee,<br>
      teaching in their synagogues, proclaiming the Gospel of the Kingdom,<br>
      and curing every disease and illness among the people. <br>
      His fame spread to all of Syria,<br>
      and they brought to him all who were sick with various diseases<br>
      and racked with pain,<br>
      those who were possessed, lunatics, and paralytics,<br>
      and he cured them. <br>
      And great crowds from Galilee, the Decapolis, Jerusalem, and Judea,<br>
      and from beyond the Jordan followed him.<br>
   </div>
</div>
</div>

我只想拉最后一部(福音)部分:Mt 4:12-17, 23-25

福音的全文:

When Jesus heard that John had been arrested,<br>he withdrew to Galilee. <br>He left Nazareth and went to live in Capernaum by the sea,<br>in the region of Zebulun and Naphtali,<br>that what had been said through Isaiah the prophet <br>might be fulfilled:<br><br><em>Land of Zebulun and land of Naphtali,<br>the way to the sea, beyond the Jordan,<br>Galilee of the Gentiles,<br>the people who sit in darkness<br>have seen a great light,<br>on those dwelling in a land overshadowed by death<br>light has arisen.</em><br><br>From that time on, Jesus began to preach and say,<br>“Repent, for the Kingdom of heaven is at hand.”<br><br>He went around all of Galilee,<br>teaching in their synagogues, proclaiming the Gospel of the Kingdom,<br>and curing every disease and illness among the people. <br>His fame spread to all of Syria,<br>and they brought to him all who were sick with various diseases<br>and racked with pain,<br>those who were possessed, lunatics, and paralytics,<br>and he cured them. <br>And great crowds from Galilee, the Decapolis, Jerusalem, and Judea,<br>and from beyond the Jordan followed him.

非常感谢我能得到的任何帮助。

3 个答案:

答案 0 :(得分:2)

看看simple html dom这样的任务。它简单如下:

$html = str_get_html("HTML_STRING"); 
$e = $html->find("div[class=poetry]", 0);
echo $e->plaintext;

答案 1 :(得分:2)

<?php   
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
//echo "you have //just comment this echo
header("location:signin.html"); //to redirect back to "index.php" after logging out
exit();
?>

答案 2 :(得分:0)

你可以使用html解析器库或使用jQuery或javascript

php库同样在这里

https://github.com/paquettg/php-html-parser