Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Object model
- var Event = function() {
- this.headline = "";
- this.hour = "";
- this.duration = "";
- this.speaker = [];
- this.company = "";
- }
- // List that will be populated w/ the final data
- var eventsList = []
- // Function to extract the info and saving in the eventsList array
- var events = () => {
- let s = document.getElementsByClassName("schedule-track");
- Array.from(s).map(i => {
- if (i.classList.length === 1) {
- // Create a new local Object
- let d = new Event;
- // Extract event information
- d.headline = i.querySelector(".break-line-h5 a:last-child").innerText;
- d.hour = i.querySelector(".schedule-hour").innerText;
- d.duration = i.querySelector(".schedule-duration").innerText;
- Array.from(i.getElementsByClassName("schedule-speaker-name")).map(o => d.speaker.push(o.lastElementChild.innerText));
- i.querySelector(".schedule-speaker-company") ? d.company = i.querySelector(".schedule-speaker-company").innerText : "";
- // Update eventsList w/ the current event
- eventsList.push(d);
- }
- });
- // Transform data to JSON and log in the console
- console.log(JSON.stringify(eventsList));
- }
Add Comment
Please, Sign In to add comment