Javascript变量导出到python
快速提问。我是否可以访问脚本中的javascript变量,然后使用它生成python图形 我在我的网站上运行javascript脚本,我需要在离开网站后“导出”脚本中的变量,然后在其他地方运行的python脚本中使用它。我的网站是一个基本的html页面,收集有关其使用情况的数据Javascript变量导出到python,javascript,python,Javascript,Python,快速提问。我是否可以访问脚本中的javascript变量,然后使用它生成python图形 我在我的网站上运行javascript脚本,我需要在离开网站后“导出”脚本中的变量,然后在其他地方运行的python脚本中使用它。我的网站是一个基本的html页面,收集有关其使用情况的数据 window.onload = function(){ var heatmapInstance = h337.create({ container: document.querySelector('.
window.onload = function(){
var heatmapInstance = h337.create({
container: document.querySelector('.heatmap'),
radius: 90
});
document.querySelector('.heatmap').onmousemove = function(ev) {
heatmapInstance.addData({
x: ev.layerX,
y: ev.layerY,
value: 1
});
};
}
function getHeatMap() {
var currentData = heatmapInstance.getData();
return currentData;
}
在受支持的浏览器中,当用户关闭后端的选项卡时,可以使用刷新数据
window.onload = window.onunload = function analytics(event) {
if (!navigator.sendBeacon) return;
var url = "https://example.com/analytics";
// Create the data to send
var data = "state=" + event.type + "&location=" + location.href;
// Send the beacon
var status = navigator.sendBeacon(url, data);
// Log the data and result
console.log("sendBeacon: URL = ", url, "; data = ", data, "; status = ", status);
};