最新方法:
https://mdetail.tmall.com/templates/pages/desc?id= + 商品ID
新的暂用的方法是
这个接口的 pcDescContent 字段
下面的方法都挂了
获取商品详情图API - 淘宝联盟API免费API接口-淘宝联盟API开放API接口-淘宝联盟APICPS接口-喵有券(www.ecapi.cn) 我现在用的是他家的接口 下面的接口不能用了
$.ajax({
url: "https://hws.m.taobao.com/cache/desc/5.0?id=" + id,//淘宝商品ID
timeout: 1000,
tryCount: 0,
retryLimit: 3,
dataType: 'jsonp',
jsonp: 'callback',
success: function (result) {
if (result.sellerId != "") {
var regx = /<[^>]*>|<\/[^>]*>/gm;
var len = result.wdescContent.pages.length;
var image = "";
for (var i = 0; i < len; i++) {
if (result.wdescContent.pages[i].indexOf("<txt>") != -1) {
image += "";
} else {
image += "<img src='http:" + result.wdescContent.pages[i].replace(regx, "") + "' style='width:100%;max-width:100%'>";
}
}
//console.log(image);
$('.good_detail').html(image);
}
}
});
我不知道 其他人 进行到$('.good_detail').html(image); 这一步有没有输出不了的情况,我这里没有反应,html() 里面放字符串或其他都能输出,就是放 image不行 。。
测试的可行方法是,把result.wdescContent.pages[i] url 数据发送到后端再返回给前端重组 img字符串 就能输出了。。