我想用Python 中的JavaScript 运行此代码,以获取图像路径并将其打印或存储在csv中(PyV8,js2py,BeautifulSoup或seleniumto)文件,因此我要打印“ data:image / png; base64,iVBORw0KGgo ~~”之类的图像路径
非常感谢,新年快乐!
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
curveType: 'function',
legend: {
position: 'bottom'
}
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
google.visualization.events.addListener(chart, 'ready', function() {
curve_chart.innerHTML = '<img src="' + chart.getImageURI() + '">';
console.log(curve_chart.innerHTML);
});
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
</body>
</html>