[英]how to exract text between specific tags in html with php and regex?
我已经在stackoverflow中搜索了我的答案,但找不到任何东西。
我的问题是如何提取特定标签之间的特定文本,以及如果文本的第一个单词在标签内找到,它将抓住它直到结尾
这是我的代码
$homepage = file_get_contents('http://www.time.com/');
$homepage=htmlentities($homepage);
echo $homepage;
例如它给我这个输出
<div>
<span class="12334d">first text in url</span>
<span id="asdasd2">second text in url</span> <br />
<span class="ddie8">third text in url</span>
<span>something else in url</span> <br/>
<span>special thing is here</span>
<span>something else in web</span>
</div>
所以我想用regex抓取“ url中的其他内容 ”和“ web中的其他内容 ”,当它找到第一个单词“ something ”时,抓取文本直到...之间的结尾并将其放入字符串中。 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.