批量下载阿里巴巴商品图片工具

开了个网店,

要从阿里巴巴进货,顺便从进货商的商品介绍上把图片保存到我自己的店里用,

阿里巴巴图片不让存。。

虽然可以看源代码的方式找到图片地址然后保存,但是这样太累,

做个小工具:

用的是aauto这个语言,前两天刚看到的这么个语言,语法简单灵活,做个小软件正合适,

思路很简单,如下:

第一步,加载商品页面:(因为阿里巴巴这个页面是随着滚动条的位置才加载内容的,所以加载后需要滚动到页面底部)

var wb1 = web.form(static,,);        
wb1.go(url); 
wb1.wait();
//页面上使用了lazyload,所以必须滚动到底部,才能加载到内容
var scrollScript="self.scroll(0,65000);";
wb1.doScript(scrollScript);
win.delay(500);
wb1.document.documentElement.scrollTop=65000;

第二步,找到图片地址

//预览图
        qEle =wb1.waitQueryEles(id="dt-tab");
        var photocontainer = qEle[1].innerHTML;
        //console.log( photocontainer  );
        regex = string.regex('"original":"(.*?)"}') ;
        regex.global = 1;
        regex.ignoreCase = 1;
        
         for i,regex_match in regex.gmatch(photocontainer){
            table.push(imgTable,regex_match.SubMatches(0));
        }
    
        
        //内容图
        qEle = wb1.waitQueryEles(
                     className= "de-description-detail");
        
        var content= qEle[1].innerHTML;
        regex = string.regex('<img.+?src=\"([^\"]*?)\".*?>') ;
        regex.global = 1;
        regex.ignoreCase = 1;
        for i,regex_match in regex.gmatch(content){
            //console.log( ( regex_match.SubMatches(0) ) );
            table.push(imgTable,regex_match.SubMatches(0));
        }

第三步,下载图片

src=http1.get(fileurl);
string.save(newDir+"\商品图片_"+filename ,src);

完成,图片轻松的下载下来了

以上。

转载于:https://www.cnblogs.com/terrorpig/archive/2012/10/16/2725483.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值