I an trying to extract information using simple_html_dom.php
The line looks like this:
<meta itemprop="openingHours" content="Mo,Tu,We,Th,Fr,Sa,Su 08:00-00:00">
I need the "Mo,Tu,We,Th,Fr,Sa,Su 08:00-00:00" part.
Here is what I tried so far:
$url="https://www1.shoppersdrugmart.ca/en/store-locator/store/668";
include ('../classes/simple_html_dom.php');
$html = file_get_html($url);
//this works fine
$eg = $html->find('dd[itemprop="telephone"]');
echo "Phone: ".$eg[0]->plaintext. "<br>";
//this does not work
$eg = $html->find('meta[itemprop="openingHours"]');
echo "openingHours: ". $eg['content']->plaintext. "<br>";
$oh_content=$html->find('meta[itemprop="openingHours"]')->attr("content");
echo $oh_content."*<br>";
$oh_content1=$html->find('meta[itemprop="openingHours"]')->content;
echo $oh_content1."*<br>";
As in $eg = $html->find('dd[itemprop="telephone"]');
$eg
is array of filtered nodes, then it is true for your second find
:
$eg = $html->find('meta[itemprop="openingHours"]');
// $eg is array:
var_dump($eg[0]->content);
In case someone need it, here is the code that works:
$url="https://www1.shoppersdrugmart.ca/en/store-locator/store/668";
include ('../classes/simple_html_dom.php');
$html = file_get_html($url);
$eg = $html->find('dd[itemprop="telephone"]');
echo "Phone: ".$eg[0]->plaintext. "<br>";
$eg = $html->find('meta[itemprop="openingHours"]');
echo "openingHours: ". $eg[0]->content. "<br>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.