当前位置: 丝域 > 丝友交流 > 查看内容
个人中心
登录用户:未登录
帐户类型:游客
VIP有效期: - (未登陆)
联系管理员
站内消息
批量下载套图
我的下载队列
我的收藏夹
我的推广记录
兑换码
# coding=utf-8

import time
import wget
import requests as req
import re

def get_images(_imgnumber):
    '''
    用于得到图片的地址并下载
    '''
    requestUrl = "http://www.artofgloss.net/preview/displayimage.php?album=lastup&cat=0&pos=" + str(_imgnumber)
    attempts = 0
    success = False
    while attempts < 3 and not success:
        try:
            resp = req.get(requestUrl)
            success = True
        except:
            time.sleep(5)
            attempts += 1
            if attempts == 3:
                print("\n网页获取失败")
                break

    result = re.search('src="(albums/\S*.jpg)"', resp.text)
    if "thumb" in result.group(1):
        result = re.search('src="(albums/\S*.gif)"', resp.text)
    fullhttp = "http://www.artofgloss.net/preview/" + result.group(1)
    newfullhttp = fullhttp.replace("normal_", "")
    print("\n",_imgnumber)
    print(newfullhttp)
    wget.download(newfullhttp, 'G:/temp')
    if ("00.jpg" in newfullhttp):
        collecthttp = newfullhttp.replace("00.jpg", "02.jpg")
        print("\n", collecthttp)
        try:
            wget.download(collecthttp, 'G:/temp')
        except:
            print("\n文件不存在")

if __name__ == "__main__":
    for imgnumber in range(0, 100):
        get_images(imgnumber)

说明:1.文件默认存储在G:/temp目录下;2.程序默认下载从0-100编号的图片,你可以自行修改for imgnumber in range(0, 100)这条语句里面的起始编号和结束编号。目前可用的编号大概是6000多。
回复本帖
  1. 还没有人发表评论