首页 > 编程语言 > 详细

Python 下载1号店的图片 主图和详情图

时间:2020-04-08 00:02:55      阅读:75      评论:0      收藏:0      [点我收藏+]

code:

import requests

# 原文:https://blog.csdn.net/z564359805/article/details/81978913


#arr=["https://img.yzcdn.cn/upload_files/2018/01/02/FqA8rXxHIDfQmzoj1RWTgjUGP-Xd.jpg!large.jpg", "https://img.yzcdn.cn/upload_files/2018/01/02/FiROAvlyF2TmAyfOyFNHFxzNDPx_.jpg!large.jpg", "https://img.yzcdn.cn/upload_files/2017/08/30/150407378492131464.jpg!large.jpg", "https://img.yzcdn.cn/upload_files/2017/08/30/150407378531683138.jpg!large.jpg", "https://img.yzcdn.cn/upload_files/2017/08/30/150407378578049923.jpg!large.jpg"]
#arr=["https://img.yzcdn.cn/upload_files/2018/04/03/dcce240f4721cd52bf206fe4e321d9cd.gif", "https://img.yzcdn.cn/upload_files/2018/04/06/e2abd494186c873fca83a8fedff6e8bf.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/fdad8296c7324cab34343b7ad1bed86f.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/6dfa4980b35b785d562d444c5ad3d220.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/2754bbd6a171d364448d626ca3bc9a69.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/4818138365b7f1499193e4d054cb040a.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/f581d4925b5ed47b2229d6f0842f69e3.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/c0f7a686dd4caadfd8109d0c7465ba85.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/bfd621e83ade34e4b3eacd6ea9cf0c40.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/e0d22b68f6f72d8599c9b8d537b85588.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/f65914422c15adbd9378bbd0808c0f87.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/110a9fda03ae1b7ca1d94c0e11f57247.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/2bccaa64b82f091abde00c56ca175258.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/2b45f51bc2ec1f5bc331491881382b54.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/28cde66fd2bb00a9c32c40f36402ac21.jpg!730x0.jpg", "https://img.yzcdn.cn/upload_files/2018/04/06/838134dfa244279d53377b3ec16d8fea.jpg!730x0.jpg"]
#arr=["http://img14.360buyimg.com/n1//s1920x1920_jfs/t1/74799/1/2408/305398/5d0b2d66E0f4005f4/7cd8a347aa71fc52.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t1/37023/20/5239/287002/5cbe9e8eEc956d5ad/9cc3aa86f63aa429.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t16807/31/1377510268/125390/addaae28/5ac9c16aN8716d129.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t5386/229/2450419968/87827/bc0461f3/591acedeNb3c4ec02.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t4465/298/2263977719/127571/6a460537/591acedfNb73e9406.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t5500/62/2319057658/112674/bfecccc0/591acedfN41aa0865.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t5377/109/2454228486/30171/b1b8ca8f/591acee0N57370001.jpg","http://img14.360buyimg.com/n1//s1920x1920_jfs/t5362/64/2402222553/45131/782d0368/591acee0Ne00e2369.jpg"]
arr=["https://img30.360buyimg.com/sku/jfs/t1/99487/1/975/293557/5db7d91bEa8954c04/0ac7f08e20c6f327.jpg","https://img30.360buyimg.com/sku/jfs/t1/51631/24/14350/303155/5db7d91bE948e6574/2e88baefbec2dd02.jpg","https://img30.360buyimg.com/sku/jfs/t1/62910/29/14109/306538/5db7d91bEb9371038/7966cf3746d1099e.jpg","https://img30.360buyimg.com/sku/jfs/t1/105860/14/968/305319/5db7d91bEfd8558ee/e5eb99eb8a8a10be.jpg","https://img30.360buyimg.com/sku/jfs/t1/84410/27/14173/300244/5db7d91bE88bb023a/8e322818be00d3ed.jpg","https://img30.360buyimg.com/sku/jfs/t1/70863/30/14151/304145/5db7d91bE6fad2958/2602c2bdb00db1c2.jpg","https://img30.360buyimg.com/sku/jfs/t1/70953/37/14284/306224/5db7d91bE15584265/968e22b04eba7005.jpg","https://img30.360buyimg.com/sku/jfs/t1/63753/28/13973/306213/5db7d91bEa15e31c5/f77ff9e2a969b291.jpg","https://img30.360buyimg.com/sku/jfs/t1/82535/35/13977/307471/5db7d91bE2084d3b9/c0649979c2f9eecf.jpg","https://img30.360buyimg.com/sku/jfs/t1/100753/38/982/174400/5db7d91bEa6bce9c8/14415d5a528cbf8a.jpg"]


# 1号店主图
‘‘‘
var imgs = document.getElementById(‘jsproCrumb‘).getElementsByTagName(‘img‘);
var str = ‘‘;
for (i = 0; i < imgs.length; i++) { 
    str += ‘"http://img14.360buyimg.com/n1//s1920x1920_‘ + imgs[i].getAttribute(‘original_src‘) + ‘",‘; }
console.log(str);
‘‘‘

# 1号店详情图
‘‘‘
var imgs = document.getElementsByClassName(‘ssd-module-wrap‘)[0].getElementsByClassName(‘ssd-module‘);
var str = ‘‘;
for (i = 0; i < imgs.length; i++) {
    var src = $(imgs[i]).css("backgroundImage").replace(‘url(‘, ‘‘).replace(‘)‘, ‘‘);
    str += src + ‘,‘;
}
console.log(str);
‘‘‘




print(len(arr))
for inx, val in enumerate(arr):
    print(inx)
    html = requests.get(val)
    with open("C:/data/1/"+str(inx)+".jpg","wb")as f:
        f.write(html.content)



Python 下载1号店的图片 主图和详情图

原文:https://www.cnblogs.com/guxingy/p/12657005.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!