[英]How to select content without element using simplehtmldom
I am trying to extract data from a website using PHP with the help of simplehtmldom. 我正在尝试在simplehtmldom的帮助下使用PHP从网站中提取数据。
The problem is that there is a text which doesn't have any parent element. 问题在于,有一个文本没有任何父元素。
<div class="div_1">First div</div> The text i need to grab <div class="div_2">Second div</div>
In the above demonstration i need to extract The text i need to grab
. 在上面的演示中,我需要提取
The text i need to grab
。
If simplehtmldom is not required, try Regular Expressions: 如果不需要simplehtmldom,请尝试使用正则表达式:
<div[^<>]*class="div_1"[^<>]*>.*?</div>(.*?)<div[^<>]*class="div_2"[^<>]*>.*?</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.