コード例 #1
0
def save_photo_links(photo_inform):
    global PATH_TO_PHOTOS_LINKS
    u_id = photo_inform[0]  # user id
    number = photo_inform[1]  # number photo from user
    photo_link = photo_inform[2]  # link to photo
    my_csv.csv_line_writer(PATH_TO_PHOTOS_LINKS, [u_id, number, photo_link])
    pass
コード例 #2
0
def write_csv_head():
    my_csv.csv_line_writer(PATH_TO_USERS_INFORMATION, [
        'id_user', 'link_to_user', 'имя', 'пол', 'тип аккаунта', 'возраст',
        'страна', 'город', 'о себе', 'кого ищет', 'семейное положение',
        'доход', 'материальное положение', 'проживание', 'наличие автомобиля',
        'отношение к курению', 'отношение к алкоголю', 'знание языков',
        'рост, см', 'вес, кг', 'цвет волос', 'цвет глаз', 'телосложение',
        'татуировки', 'пирсинг', 'волосы на лице и на теле', 'ориентация',
        'тип секса', 'роль', 'позы', 'действия', 'эрогенные зоны', 'фетиши'
    ])
    my_csv.csv_line_writer(PATH_TO_PHOTOS_LINKS,
                           ['id_user', 'number_of_photo', 'link_to_photo'])
    information('CSV head created successful.')
コード例 #3
0
def save_photo(photo_inform):
    global ALL_PROXY
    u_id = photo_inform[0]
    number = photo_inform[1]
    photo_link = photo_inform[2]
    photo_big_link = photo_link.replace('800x800', '1200x1200')
    now_proxy = ALL_PROXY[random.randint(0, len(ALL_PROXY) - 1)]
    to_get = {'http': now_proxy}
    to_save = requests.get(photo_big_link, proxies=to_get)
    if to_save.status_code == 404:
        to_save = requests.get(photo_link, proxies=to_get)
    global PATH_TO_PHOTOS, PATH_TO_PHOTOS_LINKS
    photo_name = PATH_TO_PHOTOS + '/{}_{}.jpg'.format(u_id, number)  # user_id + photo number
    out = open(photo_name, "wb")
    out.write(to_save.content)
    out.close()
    my_csv.csv_line_writer(PATH_TO_PHOTOS_LINKS, [number, photo_link])
    pass
コード例 #4
0
def scr_user(dr, link_to_user, region_code):
    dr = auth(dr)
    dr.get(link_to_user)
    try:
        dr.find_element_by_class_name('info-404')
        # write_csv(path_to_users_information, [[id_user, 'User']])
    except selenium_exception.NoSuchElementException:
        id_user = link_to_user.link_to_user.replace('http://beboo.ru/profile/',
                                                    '').replace('?from=1', '')
        name = find_by('class', 'profile-nick-name', dr).partition('\n')[0]
        sex = find_by('id', 'val_age', dr)
        type_of_account = find_by('tag_1', 'dd', dr)
        age = find_by('tag_2', 'dd', dr)
        country = region_code
        # country = '1'  # сделать подстановку из словаря, ищем по строке
        # driver.find_element_by_class_name('look_for').text и если совпадает со страной из списка, подставляем её
        city = find_by('tag_4', 'dd', dr)
        about = find_by('tag_6', 'p', dr)
        find = find_by('tag_7', 'p', dr)

        # about
        family = find_by('id', 'val_25', dr)  # семейное положение
        profit = find_by('id', 'val_26', dr)  # доход
        financial_situation = find_by('id', 'val_27',
                                      dr)  # материальное положение
        accommodation = find_by('id', 'val_28', dr)  # проживание
        auto = find_by('id', 'val_29', dr)  # наличие автомобиля
        smoke = find_by('id', 'val_30', dr)  # отношение к курению
        alco = find_by('id', 'val_31', dr)  # отношение к алкоголю
        language = find_by('id', 'val_32', dr)  # знание языков

        # look
        height = find_by('id', 'val_height', dr).replace(' см', '')  # рост, см
        weight = find_by('id', 'val_weight', dr).replace(' кг', '')  # вес, кг
        head_color = find_by('id', 'val_23', dr)  # цвет волос
        eye_color = find_by('id', 'val_24', dr)  # цвет глаз
        body = find_by('id', 'val_19', dr)  # телосложение
        tatoo = find_by('id', 'val_20', dr)  # татуировки
        piercing = find_by('id', 'val_21', dr)  # пирсинг !!!
        other_hair = find_by('id', 'val_22', dr)  # волосы на лице и на теле

        # sexual preferences
        orientation = find_by('id', 'val_33', dr)  # ориентация
        type_of_sex = find_by('id', 'val_35', dr)  # тип секса
        role_of_sex = find_by('id', 'val_34', dr)  # роль
        favorite_poses_in_sex = find_by('id', 'val_36', dr)  # позы
        to_do = find_by('id', 'val_37', dr)  # действия !!!
        erogenous_zones = find_by('id', 'val_38', dr)  # эрогенные зоны
        fetishes = find_by('id', 'val_39', dr)  # фетиши

        global PATH_TO_USERS_INFORMATION
        my_csv.csv_line_writer(PATH_TO_USERS_INFORMATION, [
            id_user, link_to_user, name, sex, type_of_account, age, country,
            city, about, find, family, profit, financial_situation,
            accommodation, auto, smoke, alco, language, height, weight,
            head_color, eye_color, body, tatoo, piercing, other_hair,
            orientation, type_of_sex, role_of_sex, favorite_poses_in_sex,
            to_do, erogenous_zones, fetishes
        ])

        users_photos_links = get_links_to_photo(dr)

        # users_photos_links_to_save = []
        # for i in range(len(users_photos_links)):
        #     users_photos_links_to_save.append([id_user, users_photos_links[i][0], users_photos_links[i][1]])
        [this.insert(0, id_user)
         for this in users_photos_links]  # add user id to photo
        # TODO: save photos links

        pass
    pass
コード例 #5
0
def scr_user(dr, number_user, link_to_user, region_code):
    global GRAY_USERS, WHITE_USERS, BLACK_USERS, PATH_TO_USERS_INFORMATION
    dr.get(link_to_user)
    try:
        dr.find_element_by_class_name('info-404')
        BLACK_USERS += 1

    except selenium_exception.NoSuchElementException:
        WHITE_USERS += 1
        id_user = link_to_user.replace('http://beboo.ru/profile/', '').replace('?from=1', '')

        information(
            'User {} (user id is {}) is scrapped with photo(-s). Now {}/{} users done ({}%), {} is dead.'.format(
                        number_user + 1,
                        id_user,
                        WHITE_USERS,
                        GRAY_USERS,
                        round(((number_user + 1 + BLACK_USERS) / GRAY_USERS) * 100, 2),
                        BLACK_USERS
            )
        )

        name = find_by('bad_username', 'profile-nick-name', dr).partition('\n')[0]
        sex = find_by('id', 'val_age', dr)
        type_of_account = find_by('tag_1', 'dd', dr)
        age = find_by('tag_2', 'dd', dr)
        country = region_code
        # country = '1'  # сделать подстановку из словаря, ищем по строке
        # driver.find_element_by_class_name('look_for').text и если совпадает со страной из списка, подставляем её
        city = find_by('tag_4', 'dd', dr)
        about = find_by('tag_6', 'p', dr).replace('\n', '; ')
        find = find_by('tag_7', 'p', dr).replace('\n', '; ')

        # about
        # additionally = dr.find_element_by_name('advTab')
        # additionally.click()
        family = find_by('id', 'val_25', dr)  # семейное положение
        profit = find_by('id', 'val_26', dr)  # доход
        financial_situation = find_by('id', 'val_27', dr)  # материальное положение
        accommodation = find_by('id', 'val_28', dr)  # проживание
        auto = find_by('id', 'val_29', dr)  # наличие автомобиля
        smoke = find_by('id', 'val_30', dr)  # отношение к курению
        alco = find_by('id', 'val_31', dr)  # отношение к алкоголю
        language = find_by('id', 'val_32', dr)  # знание языков

        # look
        height = find_by('id', 'val_height', dr).replace(' см', '')  # рост, см
        weight = find_by('id', 'val_weight', dr).replace(' кг', '')  # вес, кг
        head_color = find_by('id', 'val_23', dr)  # цвет волос
        eye_color = find_by('id', 'val_24', dr)  # цвет глаз
        body = find_by('id', 'val_19', dr)  # телосложение
        tatoo = find_by('id', 'val_20', dr)  # татуировки
        piercing = find_by('id', 'val_21', dr)  # пирсинг !!!
        other_hair = find_by('id', 'val_22', dr)  # волосы на лице и на теле

        # sexual preferences
        orientation = find_by('id', 'val_33', dr)  # ориентация
        type_of_sex = find_by('id', 'val_35', dr)  # тип секса
        role_of_sex = find_by('id', 'val_34', dr)  # роль
        favorite_poses_in_sex = find_by('id', 'val_36', dr)  # позы
        to_do = find_by('id', 'val_37', dr)  # действия !!!
        erogenous_zones = find_by('id', 'val_38', dr)  # эрогенные зоны
        fetishes = find_by('id', 'val_39', dr)  # фетиши

        my_csv.csv_line_writer(PATH_TO_USERS_INFORMATION, [
            id_user, link_to_user, name, sex, type_of_account, age, country, city, about, find, family, profit,
            financial_situation, accommodation, auto, smoke, alco, language, height, weight, head_color, eye_color,
            body, tatoo, piercing, other_hair, orientation, type_of_sex, role_of_sex, favorite_poses_in_sex, to_do,
            erogenous_zones, fetishes
        ])

        users_photos_links = get_links_to_photo(dr)

        [this.insert(0, id_user) for this in users_photos_links]  # add user id to photo
        #  save photos links
        for photo_plus in users_photos_links:
            save_photo(photo_plus)
        pass
    pass