You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know Javscript syntax so please excuse any mistakes I might be typing.
There is one HTML element from a website I want to write to a text file so that I can read it in Python. I ran this code below intending to do that:
var el = document.getElementsByClassName("exc-param-dr-date hasDatepicker")[0];
el.appendChild(document.createTextNode("Test"));
var tmp = document.createElement("div");
tmp.appendChild(el);
var sh = console.log(tmp.innerHTML);
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)
console.save(tmp.innerHTML,['to-date.json'])
I was able to successfully write that element to a text file. However, that same element then disappeared from the html code afterwards. How can I avoid this?
The text was updated successfully, but these errors were encountered:
I don't know Javscript syntax so please excuse any mistakes I might be typing.
There is one HTML element from a website I want to write to a text file so that I can read it in Python. I ran this code below intending to do that:
var el = document.getElementsByClassName("exc-param-dr-date hasDatepicker")[0];
el.appendChild(document.createTextNode("Test"));
var tmp = document.createElement("div");
tmp.appendChild(el);
var sh = console.log(tmp.innerHTML);
(function(console){
console.save = function(data, filename){
}
})(console)
console.save(tmp.innerHTML,['to-date.json'])
I was able to successfully write that element to a text file. However, that same element then disappeared from the html code afterwards. How can I avoid this?
The text was updated successfully, but these errors were encountered: