image auto downloader
image auto downloader
icons killer / js crawler
http only + same-origin
OK
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2020-10-01
* @modified
*
* @description image auto downloader
* @difficulty Easy Medium Hard
* @complexity O(n)
* @augments
* @example
* @link
* @solutions
*
* @best_solutions
*
*/
const log = console.log;
let divs = [...document.querySelectorAll(`.learn-path-item`)];
for (let i = 0; i < divs.length; i++) {
const div = divs[i];
const img = div.firstElementChild;
// log(`img src =`, img.src);
// window.open(img.src);
autoDownloader(img.src, 1000);
}
const autoDownloader = (url = ``, timer = 0) => {
const body = document.querySelector(`body`);
const a = document.createElement(`a`);
//
a.setAttribute(`href`, url);
a.setAttribute(`download`, true);
// a.setAttribute(`download`, ``);
a.setAttribute(`style`, `display:none;`);
body.insertAdjacentElement(`beforeend`, a);
a.click();
setTimeout(() => {
// DOM remove
body.removeChild(a);
// a.remove();
// delete a;
}, timer);
}
demo
cross-origin bug
www.lanqiao.cn !== dn-simplecloud.shiyanlou.com

https://dn-simplecloud.shiyanlou.com/1487741005890.png
解决方案
a 域名下面,获取 icons urls, 存储 urls (https://www.lanqiao.cn/paths/)
b 域名下面,遍历 urls, 下载 icons (https://dn-simplecloud.shiyanlou.com)
const log = console.log;
let divs = [...document.querySelectorAll(`.learn-path-item`)];
const urls = [];
for (let i = 0; i < divs.length; i++) {
const div = divs[i];
const img = div.firstElementChild;
urls.push(img.src);
}
// chrome copy
copy(urls);
进入 https://dn-simplecloud.shiyanlou.com/ 域名页面
const urls = [
"https://dn-simplecloud.shiyanlou.com/1487741005890.png",
"https://dn-simplecloud.shiyanlou.com/course/1555406408145_%E3%80%90%E8%B7%AF%E5%BE%84%E3%80%91-%E3%80%90Python%E7%A0%94%E5%8F%91%E5%B7%A5%E7%A8%8B%E5%B8%88%E3%80%91.png",
"https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501840618053.png",
"https://dn-simplecloud.shiyanlou.com/course/1550137107333_%E3%80%90%E8%B7%AF%E5%BE%84%E3%80%91-%E3%80%90%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%B7%A5%E7%A8%8B%E5%B8%88%E3%80%91.png",
"https://dn-simplecloud.shiyanlou.com/1487738666016.png",
"https://dn-simplecloud.shiyanlou.com/1487741048998.png",
"https://dn-simplecloud.shiyanlou.com/1487741143862.png",
"https://dn-simplecloud.shiyanlou.com/course/1582622893410_%E8%AE%A1%E7%AE%97%E6%9C%BA%E4%B8%93%E4%B8%9A%E8%AF%BE%E5%B0%81%E9%9D%A2.png",
"https://dn-simplecloud.shiyanlou.com/course/1552356927768_%E3%80%90%E8%B7%AF%E5%BE%84%E3%80%91-%E3%80%90Java%E7%A0%94%E5%8F%91%E5%B7%A5%E7%A8%8B%E5%B8%88%E3%80%91.png",
"https://dn-simplecloud.shiyanlou.com/1487741188918.png",
"https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501839495188.png",
"https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501837346458.png",
"https://dn-simplecloud.shiyanlou.com/course/1552356125250_%E3%80%90%E8%B7%AF%E5%BE%84%E3%80%91-%E3%80%90Web%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E5%B8%88%E3%80%91.png",
"https://dn-simplecloud.shiyanlou.com/1487741227106.png",
"https://dn-simplecloud.shiyanlou.com/1487738611078.png",
"https://dn-simplecloud.shiyanlou.com/assets/1596261479814_1596251235455_%E7%BC%96%E7%BB%84%202.png"
];
// 进入 https://dn-simplecloud.shiyanlou.com/ 域名页面
for (const url of urls.length) {
autoDownloader(url, 1000);
}
const autoDownloader = (url = ``, timer = 0) => {
const body = document.querySelector(`body`);
const a = document.createElement(`a`);
//
a.setAttribute(`href`, url);
a.setAttribute(`download`, true);
// a.setAttribute(`download`, ``);
a.setAttribute(`style`, `display:none;`);
body.insertAdjacentElement(`beforeend`, a);
a.click();
setTimeout(() => {
// DOM remove
body.removeChild(a);
// a.remove();
// delete a;
}, timer);
}
OK


why missing some icons???

bug urls

https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501839495188.png
https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501837346458.png
https://dn-simplecloud.shiyanlou.com/course/1552356125250_【路径】-【Web前端工程师】.png
https://dn-simplecloud.shiyanlou.com/1487741227106.png
https://dn-simplecloud.shiyanlou.com/1487738611078.png
https://dn-simplecloud.shiyanlou.com/assets/1596261479814_1596251235455_编组 2.png

// test
const urls = [
"https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501839495188.png",
"https://dn-simplecloud.shiyanlou.com/uid/c7edc0e1f2cfc8f40d1b699aaa32766b/1501837346458.png",
"https://dn-simplecloud.shiyanlou.com/course/1552356125250_%E3%80%90%E8%B7%AF%E5%BE%84%E3%80%91-%E3%80%90Web%E5%89%8D%E7%AB%AF%E5%B7%A5%E7%A8%8B%E5%B8%88%E3%80%91.png",
"https://dn-simplecloud.shiyanlou.com/1487741227106.png",
"https://dn-simplecloud.shiyanlou.com/1487738611078.png",
"https://dn-simplecloud.shiyanlou.com/assets/1596261479814_1596251235455_%E7%BC%96%E7%BB%84%202.png"
];
const autoDownloader = (url = ``, timer = 0) => {
const body = document.querySelector(`body`);
const a = document.createElement(`a`);
//
a.setAttribute(`href`, url);
a.setAttribute(`download`, true);
// a.setAttribute(`download`, ``);
a.setAttribute(`style`, `display:none;`);
body.insertAdjacentElement(`beforeend`, a);
a.click();
setTimeout(() => {
// DOM remove
body.removeChild(a);
// a.remove();
// delete a;
}, timer);
}
for (const url of urls) {
autoDownloader(url, 1000);
}
refs
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
image auto downloader的更多相关文章
- HTML5 download 执行条件
HTML5 download 执行条件 同一个域名下的资源 http only 绝对路径/相对路径 都可以 demo https://cdn.xgqfrms.xyz/ https://cdn.xgqf ...
- 所有selenium相关的库
通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...
- C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)
#include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...
- overflow:hidden与margin:0 auto之间的冲突
相对于父容器水平居中的代码margin:0 auto与overflow:hidden之间存在冲突.当这两个属性同时应用在一个DIV上时,在chrome浏览器中将无法居中.至于为啥我也不明白.
- Android Auto开发之一《开始学习Auto 》
共同学习,共同进步, 转载请注明出处.欢迎微信交流:sfssqs,申请注明"Android Car"字样 ================= =================== ...
- width:100%;与width:auto;的区别
<div> <p>1111</p> </div> div{ width:980px; background-color: #ccc; height:30 ...
- SQl 2005 For XMl 简单查询(Raw,Auto,Path模式)(1)
很多人对Xpath可能比较熟悉,但不知道有没有直接操作过数据库,我们都知道 在Sql2005里公支持的几种查询有Raw,Auto模式,页并没有Path和Elements用法等,如果在2000里使用过 ...
- margin:0 auto;不居中
margin:0 auto:不居中可能有以下两个的原因; 1.没有设置宽度<div style="margin:0 auto;"></div>看看上面的代码 ...
- 初学C++ 之 auto关键字(IDE:VS2013)
/*使用auto关键字,需要先赋初值,auto关键字是会根据初值来判断类型*/ auto i = ; auto j = ; cout << "auto i = 5" & ...
随机推荐
- JavaScript中的深拷贝和浅拷贝!【有错误】还未修改!请逛其他园子!
JavaScript中的深拷贝和浅拷贝! 浅拷贝 1.浅拷贝只是拷贝一层,更深层次对象级别的只拷贝引用.{也就是拷贝的是地址!简而言之就是在新的对象中修改深层次的值也会影响原来的对象!} // 2.深 ...
- 接口新建学习---cookie策略
一.为什么要添加cookie? 模拟浏览器,因为http是无状态协议,像览器一样的存储和发送Cookie,如果发送一个http请求他的响应中包含Cookie,那么Cookie Manager就会自动地 ...
- 纯手工撸一个vue框架
前言 vue create 真的很方便,但是很多人欠缺的是手动撸一遍.有些人离开脚手架都不会开发了. Vue最简单的结构 步骤 搭建最基本的结构 打开空文件夹,通过 npm init 命令生成pack ...
- GeoMesa Java API-写入与查询数据
GeoMesa Java API-写入与查询数据 写入数据 DataStore SimpleFeatureType SimpleFeature 写入 查询数据 几个常用查询条件 设置最大返回条目: 设 ...
- Java模板引擎Freemarker
Java模板引擎Freemarker 1.取值(插值)指令 2.逻辑指令:if.switch 3.字符串.集合操作 4.自定义函数 5.list排序内建函数.常用指令 6.自定义指令 7.freema ...
- hbase 集群(完全分布式)方式安装
一,环境 1, 主节点一台: ubuntu desktop 16.04 zhoujun 172.16.12.1 从节点(slave)两台:ubuntu server 16.04 hadoo ...
- mvn 多模块
mvn archetype:generate -DgroupId=com.xxx.cloud -DartifactId=myapp -Dversion=1.0.0-SNAPSHOT -Dpackage ...
- codeblocks输出中文乱码解决办法
在使用codeblocks进行编程的时候我发现控制台输出会出现中文乱码,就像这样: 所以很快我就问了老师,解决步骤如下: 一:如果源码是用codeblock编写的,打开Setting->Edit ...
- 关于数位DP的学习
---恢复内容开始--- 因为最近做比赛经常会出现数位DP,便尝试着去学学看数位DP. 先给出两篇论文的链接: <数位计数问题解法研究> <浅谈数位类统计问题> 然后也是寻找了 ...
- 【noi 2.2_1751】分解因数(递归)
题意:问一个给定正整数的分解因数的方式数.N=a1*a2*...*ak(a1<=a2<=...<=ak). 解法:一步步分解该数,总方式数为一个个因数被分解的方案数之和. 可用大括号 ...