예제 #1
0
def CheckPhotoHtml(photo_hash, data, folder_name):
    try:
        # photo info
        photo_list_text = data.find_all('li', class_="cur")[0].get_text()
        # person info
        info_list = data.find_all('p', class_="yh")[0].get_text()
        #判断性别
        sex_text = photo_list_text.split("的")[0]

        if sex_text == "他":
            sex_text = "男"
        else:
            sex_text = "女"

        base_info = sex_text + ", " + info_list
        # print(base_info)
        WriteInfo(folder_name, base_info)

        # log.info("write csv succss: " + base_info)
        # 检查图片并下载
        dls = data.find(id='phoBig').find("ul").find_all('img')

        i = 1
        photo_list = ''
        for target_list in dls:
            url = target_list.get('src')
            #print(str(i) + ", " + url)
            i = i + 1
            file_name = str(i) + ".jpg"
            # print(folder_name.split("/")[-1])
            #
            if int(configs.open_download) == 1:
                DownloadPicFile(url, folder_name, file_name)
            photo = url + ","
            photo_list += photo

        folder_info = folder_name.split('/')
        # print(folder_info)
        uid = folder_info[-1]
        photo_num = folder_info[-2]

        log.info("download  success:  " + str(photo_num) + "/" + str(uid))

        if int(configs.open_save_online) == 1:
            data = {
                'uid': uid,
                'photo_num': photo_num,
                'photo_hash': photo_hash,
                'sign': 1,
                'base_info': base_info,
                'photos': photo_list
            }
            CreateUserPhoto(data)

    except Exception as e:
        log.error("check photo error: " + photo_hash)

        data = str(photo_hash) + "," + str(folder_name)

        WriteCsv(data)
예제 #2
0
def check_html(photo_hash, data, folder_name):

    try:
        #判断性别
        photo_list_text = data.find_all(
            'li', class_="cur")[0].get_text()  # .find_all("a").get_text()
        info_list = data.find_all('p', class_="yh")[0].get_text()
        sex_text = photo_list_text.split("的")[0]
        # print(photo_list_text.split("的")[0])
        if sex_text == "他":
            sex_text = "男"
        else:
            sex_text = "女"
        base_info = sex_text + ", " + info_list
        # print(base_info)
        WriteInfo(folder_name, base_info)

        # log.info("write csv succss: " + base_info)
        #

        # 检查图片并下载
        dls = data.find(id='phoBig').find("ul").find_all('img')
        # print(dls)
        i = 1

        photo_list = ''
        for target_list in dls:
            url = target_list.get('src')
            print(str(i) + ", " + url)
            i = i + 1
            file_name = str(i) + ".jpg"
            # print(folder_name.split("/")[-1])
            DownloadFile(url, folder_name, file_name)

            photo = url + ","
            photo_list += photo

        folder_info = folder_name.split('/')
        uid = folder_info[-1]
        photo_num = folder_info[-2]

        log.info("download  success:  " + photo_num + "/" + uid + "uid:  " +
                 uid)
        data = {
            'uid': uid,
            'photo_num': photo_num,
            'photo_hash': photo_hash,
            'sign': 1,
            'base_info': base_info,
            'photos': photo_list
        }

        create_user_with_photos(data)

    except Exception as e:
        log.error("check photo error: " + photo_hash)