regex — PHP Stripping Динамический контент

Я получил URL, который я хотел бы получить часть возвращаемого текста, но я не уверен, как это сделать. Вот что в данный момент возвращает мой локон:

<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.

Любая помощь, которую я могу получить, очень ценится.

0

Решение

Взгляни на простой HTML-дом для такой задачи, как это. Это так же просто, как следующее:

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

Другие решения

#download here http://simplehtmldom.sourceforge.net/
#example to
include('simple_html_dom.php')$html = file_get_html('http://yourpage.com/');
$resultArr= array();
foreach($html->find('div.poetry') as $e)
$temp =$e->innertext;
array_push($resultArr,$temp);

echo $result = $resultArr[0];
2

Вы можете использовать библиотеку html-анализатора или jQuery или javascript

Библиотека PHP для же здесь

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

0
По вопросам рекламы [email protected]