Exemple #1
0
import photo_module as m
import os

while True:
    photo_name = input("請輸入要下載的圖片名稱: ")

    download_num = int(input("請輸入要下載的數量: "))

    photo_list = m.get_photolist(photo_name, download_num)

    if photo_list == None:
        print("找不到圖片, 請換關鍵字再試試看")
    else:
        if len(photo_list) < download_num:
            print("找到的相關圖片僅有", len(photo_list), "張")
        else:
            print("取得所有圖片連結")
        break

folder_name = m.create_folder(photo_name)

print("開始下載...")

for i in range(len(photo_list)):
    m.download_pic(photo_list[i],
                   folder_name + os.sep + photo_name + os.sep + str(i + 1))

print("\n下載完畢")
Exemple #2
0
# photo parser main progaom
# Author:Norman Chen
# -*- coding:utf-8 -*-
# import necessary library
import photo_module as pm
import PicDownload as PD
import os

while True:

    photo_name, download_num, folder_name = pm.create_folder()

    photo_list = pm.getPhotolist(photo_name, download_num)

    if photo_list == None:
        print(
            "[INFO] ===> There is nothing to be found, please correct keyword ....."
        )
        os.rmdir(folder_name + os.sep + photo_name)  # remove the wrong folder

    elif photo_name is False:  # there is the same folder name as keyword
        print(
            "[INFO] ===> There is same folder name, please input photo folder name again ...."
        )

    else:
        if len(photo_list) < download_num:
            print("[INFO] ===> Only can find", len(photo_list), "pictures")

        else:
            print(