I like the solution from Get DIV content from external Website, but I need to find the value from a DIV class which contains a specific string, like in my case btx764839 (for example). The name of the div class is not that string alone but <div class="dark btx764839">76</div>
for example.
I need the script to search for the DIV that contains btx764839 and then refer to that specific one. I've been trying many different things with strpos();
, without success. Below the script I found on the other post (without my adjustments). I would appreciate some help. Thank you very much!
$url = 'url';
$content = file_get_contents($url);
$first_step = explode( '<div class="dark btx764839">' , $content );
$second_step = explode("</div>" , $first_step[1] );
echo $second_step[0];
This is my latest attempt:
$url = 'url';
$content = file_get_contents($url);
foreach($content as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
// get class attribute of a div, it's a string
$class = $div->getAttribute('class');
// find substring 'btx764839' in $class
if (strpos($class, 'btx764839') !== false) {
echo $div->nodeValue;
}
}