在这里插入代码片 var items = document.getElementsByClassName("goods_item"); var data = []; for (var i = 0, len = items.length; i < len; i++) { var obj = {}; var item = items[i]; var oImg = item.getElementsByClassName("J_dynamic_img")[0]; obj.src = oImg.src; obj.title = item.getElementsByTagName("p")[0].innerText; obj.priceA = item.getElementsByTagName("p")[1].innerText; obj.priceB = item.getElementsByClassName('price_info')[0].innerText; obj.des = item.getElementsByClassName('fav_num')[0].innerText; data.push(obj); } console.log(data);