Esempio n. 1
0
def get_group_users(group_webpage):
    LogUtils.log_info('Processing users for group ' + group_webpage)
    group_users = dict()
    page_index = 1
    while True:
        LogUtils.log_info('Processing users page #' + str(page_index))
        users_page_url = SteamGiftsConsts.get_steamgifts_users_page(
            group_webpage) + SteamGiftsConsts.STEAMGIFTS_SEARCH_PAGE + str(
                page_index)
        html_content = WebUtils.get_html_page(users_page_url)
        if html_content is None:
            LogUtils.log_error('Cannot process users page: ' + users_page_url)
            break
        current_page_num = WebUtils.get_item_by_xpath(
            html_content, u'.//a[@class="is-selected"]/span/text()')
        if current_page_num and current_page_num != str(page_index):
            break

        user_elements = WebUtils.get_items_by_xpath(
            html_content, u'.//div[@class="table__row-outer-wrap"]')
        for user_elem in user_elements:
            user = WebUtils.get_item_by_xpath(
                user_elem, u'.//a[@class="table__column__heading"]/text()')
            group_users[user] = GroupUser(user)

        if not current_page_num:
            break

        page_index += 1

    LogUtils.log_info('Finished processing users for group ' + group_webpage)
    return group_users
Esempio n. 2
0
def is_user_in_group(user, groups_to_check):
    for group in groups_to_check:
        search_user_url = SteamGiftsConsts.get_steamgifts_users_page(SteamGiftsConsts.get_giveaway_link(group)) + SteamGiftsConsts.STEAMGIFTS_SEARCH_QUERY + user
        html_content = WebUtils.get_html_page(search_user_url, delay=delay_time)
        found_user = WebUtils.get_item_by_xpath(html_content, u'.//a[@class="table__column__heading"]/text()')
        if user == found_user:
            return True
    return False