ljsdev-ssg

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ac8bec32f53f73f81f608d6d77223d74ca6e9cdb
parent 771aa648cf96d6718819ef81c9ee923e10897eec
Author: Leon <leon@wp2static.com>
Date:   Mon, 19 Aug 2019 07:50:53 +0200

extraxct date from blog posts

Diffstat:
Mextract-title-body-date.php | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/extract-title-body-date.php b/extract-title-body-date.php @@ -40,6 +40,14 @@ if (isset($h1[0])) { $body = DOMinnerHTML($bodyel[0]); echo $body . PHP_EOL; } + + $finder = new DomXPath($xml_doc); + $dateel = $finder->query("/html/body/div/div/div/section[4]/div/div/div/div/div/div/div/ul/li[1]/a/span[2]"); + + if (isset($dateel[0])) { + $date = DOMinnerHTML($dateel[0]); + echo "<time datetime={$date}>" . PHP_EOL; + } } else { # get title (essays) $h2 = $xml_doc->getElementsByTagName( 'h2' ); @@ -63,7 +71,7 @@ if (isset($h1[0])) { if (isset($bodyel[3])) { $body = DOMinnerHTML($bodyel[3]); - echo $body PHP_EOL; + echo $body . PHP_EOL; } }