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://www.lanqiao.cn/paths/

https://dn-simplecloud.shiyanlou.com/1487741005890.png

解决方案

  1. a 域名下面,获取 icons urls, 存储 urls (https://www.lanqiao.cn/paths/)

  2. 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的更多相关文章

  1. HTML5 download 执行条件

    HTML5 download 执行条件 同一个域名下的资源 http only 绝对路径/相对路径 都可以 demo https://cdn.xgqfrms.xyz/ https://cdn.xgqf ...

  2. 所有selenium相关的库

    通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...

  3. C++11特性——变量部分(using类型别名、constexpr常量表达式、auto类型推断、nullptr空指针等)

    #include <iostream> using namespace std; int main() { using cullptr = const unsigned long long ...

  4. overflow:hidden与margin:0 auto之间的冲突

    相对于父容器水平居中的代码margin:0 auto与overflow:hidden之间存在冲突.当这两个属性同时应用在一个DIV上时,在chrome浏览器中将无法居中.至于为啥我也不明白.

  5. Android Auto开发之一《开始学习Auto 》

    共同学习,共同进步, 转载请注明出处.欢迎微信交流:sfssqs,申请注明"Android Car"字样 ================= =================== ...

  6. width:100%;与width:auto;的区别

    <div> <p>1111</p> </div> div{ width:980px; background-color: #ccc; height:30 ...

  7. SQl 2005 For XMl 简单查询(Raw,Auto,Path模式)(1)

    很多人对Xpath可能比较熟悉,但不知道有没有直接操作过数据库,我们都知道 在Sql2005里公支持的几种查询有Raw,Auto模式,页并没有Path和Elements用法等,如果在2000里使用过 ...

  8. margin:0 auto;不居中

    margin:0 auto:不居中可能有以下两个的原因; 1.没有设置宽度<div style="margin:0 auto;"></div>看看上面的代码 ...

  9. 初学C++ 之 auto关键字(IDE:VS2013)

    /*使用auto关键字,需要先赋初值,auto关键字是会根据初值来判断类型*/ auto i = ; auto j = ; cout << "auto i = 5" & ...

随机推荐

  1. Swagger-UI展示接口

    简单介绍API的管理工具Swagger的UI模块. 简介:swagger ui就是一个能整合到项目中让api的注释能够生成到一个网页上.能简单测试和给前端看. 第一步:添加引用 打开NuGet程序包管 ...

  2. babel : 无法加载文件 C:\Users\win\AppData\Roaming\npm\babel.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/ go.micros

    babel报错:babel : 无法加载文件 C:\Users\win\AppData\Roaming\npm\babel.ps1,因为在此系统上禁止运行脚本.有关详细信息,请参阅 https:/ g ...

  3. fiddler安装以及使用说明

    一.fiddler fiddler是一个抓包工具,通过使用它抓包我们可以很清晰的看到抓的内容的协议,URL,参数等. 1.安装 在普通下载网站找到安装包,直接安装,点击下一步即可. 二.使用 1.se ...

  4. 0到1:微信后台系统的演进之路 原创 张文瑞 InfoQ 2016-01-14

    0到1:微信后台系统的演进之路 原创 张文瑞 InfoQ 2016-01-14

  5. 一次I/O问题引发的P0重大故障[改版重推] 原创 二马读书 二马读书 8月16日 这是前段时间发的一篇文章,很多读者反馈,文章没有揭示故障发生的详细

    一次I/O问题引发的P0重大故障[改版重推] 原创 二马读书 二马读书 8月16日 这是前段时间发的一篇文章,很多读者反馈,文章没有揭示故障发生的详细

  6. Docker 中的网络功能介绍 外部访问容器 容器互联 配置 DNS

    Docker 中的网络功能介绍 | Docker 从入门到实践 https://vuepress.mirror.docker-practice.com/network/ Docker 允许通过外部访问 ...

  7. Defining Go Modules

    research!rsc: Go & Versioning https://research.swtch.com/vgo shawn@a:~/gokit/tmp$ go get --helpu ...

  8. Dbeaver 连接 phoenix

    Dbeaver 连接 phoenix 1.新建连接 2.选择连接类型Phoenix 3.设置驱动 4.准备驱动包 5.添加驱动 6.添加 Zookeeper Base Path 7.找到驱动类 8.配 ...

  9. 常见JVM面试题及答案整理

    常见JVM面试题及答案整理 1.什么情况下会发生栈内存溢出 2.JVM内存模型 3.JVM内存为什么要分成新生代,老年代,持久代.新生代中为什么要分为Eden和Survivor. 3.1共享内存区划分 ...

  10. linux git 命了

    #拉取远程分支代码到本地git clone -b 分支名称 sshGit路径 #更新远程代码到本地git pull #提交本地修改的代码到本地仓库git commit -m "自动打包&qu ...