微博经常发车,但图片不容易保存,教大家一个半自动的方法,就是先把整个页面图片都加载完,需要手动点击加载更多,直到加载完所有评论,在打开浏览器的审查元素功能的控制台,在console中贴入这段代码。
以Chrome浏览器为例,其他智能浏览器参照操作。
旧版微博打开页面,如:https://weibo.com/6584869435/JwWQuxhcj
先把整个页面加载完,手动点击加载更多,直到加载完所有评论。
浏览器按F12,呼出控制台,切换到console,在下方光标处粘贴代码:
- (function getUrl() {
- let imgs = document.querySelectorAll(“.list_li li > img”);
- const urls = [];
- for (let index = 0; index < imgs.length; index++) {
- urls.push(imgs[index].src.replace(“thumb180”, “large”));
- }
- copy(urls);
- return urls;
- })();
就会得到所有评论中的图片地址,已经自动复制到剪切板了,可以直接粘贴到迅雷或者其他的下载工具中批量下载。
12月17日更新一下微博大赛的下载代码
加了自动滚动,定时每1s滚动一次,如果电脑配置低或者网速不好,可以自己调整时间,调整time参数就行。
- window._cc = copy;
- let time = 1000; // 这里可以调整时间,1s=1000,2s=2000
- const timer = setInterval(() => {
- const scrollingElement = document.scrollingElement || document.body;
- scrollingElement.scrollTop = scrollingElement.scrollHeight;
- cardmore = document.querySelector(“.WB_cardmore”);
- if (cardmore) {
- clearInterval(timer);
- const myVar = setInterval(function () {
- cardmore.click();
- const scrollingElement =
- document.scrollingElement || document.body;
- scrollingElement.scrollTop = scrollingElement.scrollHeight;
- cardmore = document.querySelector(“.WB_cardmore”);
- if (!cardmore) {
- clearInterval(myVar);
- let imgs = document.querySelectorAll(“.list_li li > img”);
- const urls = [];
- for (let index = 0; index < imgs.length; index++) {
- urls.push(imgs[index].src.replace(“thumb180”, “large”));
- }
- window.urls = urls;
- window._cc(urls);
- }
- }, time);
- }
- }, time);
如果我的文章对你有帮助,欢迎移至上方按钮打赏
© 版权声明
THE END