简单快速的抓取微博各种大赛的图片地址



图片[1]-简单快速的抓取微博各种大赛的图片地址-卷生活九二零

微博经常发车,但图片不容易保存,教大家一个半自动的方法,就是先把整个页面图片都加载完,需要手动点击加载更多,直到加载完所有评论,在打开浏览器的审查元素功能的控制台,在console中贴入这段代码。

以Chrome浏览器为例,其他智能浏览器参照操作。

旧版微博打开页面,如:https://weibo.com/6584869435/JwWQuxhcj

先把整个页面加载完,手动点击加载更多,直到加载完所有评论。

浏览器按F12,呼出控制台,切换到console,在下方光标处粘贴代码:

 

  1. (function getUrl() {
  2. let imgs = document.querySelectorAll(“.list_li li > img”);
  3. const urls = [];
  4. for (let index = 0; index < imgs.length; index++) {
  5. urls.push(imgs[index].src.replace(“thumb180”, “large”));
  6. }
  7. copy(urls);
  8. return urls;
  9. })();

就会得到所有评论中的图片地址,已经自动复制到剪切板了,可以直接粘贴到迅雷或者其他的下载工具中批量下载。

12月17日更新一下微博大赛的下载代码

加了自动滚动,定时每1s滚动一次,如果电脑配置低或者网速不好,可以自己调整时间,调整time参数就行。

 

  1. window._cc = copy;
  2. let time = 1000; // 这里可以调整时间,1s=1000,2s=2000
  3. const timer = setInterval(() => {
  4. const scrollingElement = document.scrollingElement || document.body;
  5. scrollingElement.scrollTop = scrollingElement.scrollHeight;
  6. cardmore = document.querySelector(“.WB_cardmore”);
  7. if (cardmore) {
  8. clearInterval(timer);
  9. const myVar = setInterval(function () {
  10. cardmore.click();
  11. const scrollingElement =
  12. document.scrollingElement || document.body;
  13. scrollingElement.scrollTop = scrollingElement.scrollHeight;
  14. cardmore = document.querySelector(“.WB_cardmore”);
  15. if (!cardmore) {
  16. clearInterval(myVar);
  17. let imgs = document.querySelectorAll(“.list_li li > img”);
  18. const urls = [];
  19. for (let index = 0; index < imgs.length; index++) {
  20. urls.push(imgs[index].src.replace(“thumb180”, “large”));
  21. }
  22. window.urls = urls;
  23. window._cc(urls);
  24. }
  25. }, time);
  26. }
  27. }, time);
支付宝扫码打赏 微信打赏

如果我的文章对你有帮助,欢迎移至上方按钮打赏

© 版权声明
THE END
点赞0
分享