[英]Force Download Images with Javascript
I have a list of public links of Google streetview images similar to this我有一个与此类似的 Google 街景图像的公共链接列表
" https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=120&heading=120&pitch=20&key=AIzaSyC6UbcmFhZkX2q-3EyuHxl56e4zaF3L0y4 " " https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=120&heading=120&pitch=20&key=AIzaSyC6UbcmFhZkX2q-3LeyuH40
I want to automate downloading of these image files to my computer using Javascript.我想使用 Javascript 自动将这些图像文件下载到我的计算机。 Is there any Javascript library I can use for this task?是否有任何 Javascript 库可以用于此任务?
For a download link you can use a link with the "download" attribute (from here ):对于下载链接,您可以使用带有“下载”属性的链接(来自此处):
<a href="https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=120&heading=120&pitch=20&key=AIzaSyC6UbcmFhZkX2q-3EyuHxl56e4zaF3L0y4" download>Download</a>
For an automatic download you can use a script (from here ):对于自动下载,您可以使用脚本(来自此处):
<script type="text/javascript">
var link = document.createElement('a');
link.href = 'https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=120&heading=120&pitch=20&key=AIzaSyC6UbcmFhZkX2q-3EyuHxl56e4zaF3L0y4';
link.download = 'Download.jpg';
document.body.appendChild(link);
link.click();
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.