[关闭]
@dlutwuwei 2014-12-18T03:36:51.000000Z 字数 1696 阅读 650

托底上线流程

工作业务


  1. 对图片托底素材的文件名进行统一处理,下面有一个nodejs的程序,可以很方便地完成。使用时需要根据实际情况替换图片存储路径和重命名名称。

    1. var fs = require('fs');
    2. var path = 'C:\\Users\\admin360buyad\\Desktop\\M\\'; //托底图片文件目录
    3. var files = fs.readdirSync(path);
    4. for(var i=0; i<files.length; i++){
    5. console.log(files[i]);
    6. var name = files[i];
    7. var x = name.split('-');
    8. fs.rename(path + name, path + x[0]+"-"+x[1]+".jpg");//图片文件重命名位900-100.jpg高宽为名
    9. }
  2. 上传图片

  3. 备份原来的托底代码,进入http://admanager.jd.com/backupbat.html(需要配置host 192.168.129.122 admanager.jd.com, 进行备份操作。
  4. 进行批量托底替换,下面是托底替换的nodejs脚本代码,替换时需要安装request模块。使用时注意不要一次性完成,先尝试10个,20个替换完成后进行检查,在尝试替换100-200个

    1. var request = require('request');
    2. var ads = [518,519,521,522,523,524,525,526,527,528,529,530,531,532,533,534];//需要替换的广告位id号
    3. for (var i = 0; i < ads.length; i++) {
    4. var id = ads[i];
    5. (function(id) {
    6. request.get("http://admanager.jd.com/TemplateManager?adSeckill&type=searchRedis&adId=" + id + "&r=0.7934600890148431",
    7. function(err, httpResponse, body) {
    8. var res = JSON.parse(body);
    9. if (res.adSeckill == null || res.adSeckill == "") return;
    10. // 图片和链接替换
    11. // res.adSeckill = res.adSeckill.replace("http://static.360buyimg.com/ad/temp/img/td/", "http://static.360buyimg.com/ad/temp/img/td12/")
    12. // .replace("http://pinpaijie.jd.com", "http://sale.jd.com/act/YKirHPdQ2x8lqsR.html");
    13. res.adSeckill = res.adSeckill.replace("http://static.360buyimg.com/ad/temp/img/td12/","http://static.360buyimg.com/ad/temp/img/td/")
    14. .replace("http://sale.jd.com/act/YKirHPdQ2x8lqsR.html", "http://pinpaijie.jd.com" );
    15. console.info(id, res.adSeckill);
    16. (function(id) {
    17. request.post({
    18. url: 'http://admanager.jd.com/TemplateManager?userid=1', //'http://test.adcollect.jd.com/NewTemplateServlet',
    19. form: {
    20. type: 'modifyRedis',
    21. adId: id,
    22. adSeckill: res.adSeckill
    23. }
    24. }, function(err, httpResponse, body) {
    25. console.log("ad" + id + ", post successed!");
    26. });
    27. })(id);
    28. });
    29. })(id);
    30. }
  5. 检查,提交测试
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注