I am trying to get the "datePublished": value from a website's source code for my chrome extension. I want to put the value in my JavaScript file so I can use the date the website was published. How exactly would I go about doing that?
The code I want to refer to is the following:
"datePublished":"2017-09-26T20:04:13Z"
How would I get the date into my own code?
Grab the text of the DOM node and use Regex.
var element = document.getElementById("someIDcontainingThatString");
var date = element.innerText.search(/"datePublished":"(.+)"/);
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.