def update_user_additional_data(user): LogUtils.log_info('Processing SteamGifts user ' + user.user_name) html_content = WebUtils.get_html_page(SteamGiftsConsts.get_user_link( user.user_name), delay=delay_time) if html_content is None: LogUtils.log_error('Cannot update additional data for user: '******'.//div[@class="sidebar__shortcut-inner-wrap"]/a/@href') if not steam_user: LogUtils.log_error('Cannot update non-existent user: '******'.//div[@class="featured__table__row"]') for row_content in user_menu_rows: user_menu_type = WebUtils.get_item_by_xpath( row_content, u'.//div[@class="featured__table__row__left"]/text()') if user_menu_type == 'Registered': data_timestamp = float( WebUtils.get_item_by_xpath( row_content, u'.//div[@class="featured__table__row__right"]/span/@data-timestamp' )) user.creation_time = datetime.fromtimestamp(data_timestamp) break return True
def get_user_contribution_data(user_name): html_content = WebUtils.get_html_page(SteamGiftsConsts.get_user_link(user_name)) if html_content is None: LogUtils.log_error('Cannot update additional data for user: '******'.//div[@class="sidebar__shortcut-inner-wrap"]/a/@href') if not steam_user: LogUtils.log_error('Cannot update non-existent user: '******'.//div[@class="featured__table__row"]') for row_content in all_rows: row_title = WebUtils.get_item_by_xpath(row_content, u'.//div[@class="featured__table__row__left"]/text()') if row_title == u'Gifts Won': global_won = StringUtils.normalize_int(WebUtils.get_item_by_xpath(row_content, u'.//div[@class="featured__table__row__right"]/span/span/a/text()')) elif row_title == u'Gifts Sent': global_sent = StringUtils.normalize_int(WebUtils.get_item_by_xpath(row_content, u'.//div[@class=" featured__table__row__right"]/span/span/a/text()')) elif row_title == u'Contributor Level': user_level_item = WebUtils.get_item_by_xpath(row_content, u'.//div[@class="featured__table__row__right"]/span/@data-ui-tooltip') level = StringUtils.normalize_float(user_level_item.split('name" : "')[2].split('", "color')[0]) if global_won or global_sent or level: return global_won, global_sent, level return None
def update_user_additional_data(user): LogUtils.log_info('Processing SteamGifts user ' + user.user_name) html_content = WebUtils.get_html_page( SteamGiftsConsts.get_user_link(user.user_name)) if html_content is None: LogUtils.log_error('Cannot update additional data for user: '******'.//div[@class="sidebar__shortcut-inner-wrap"]/a/@href') if not steam_user: LogUtils.log_error('Cannot update non-existent user: ' + user.user_name) return False user.steam_id = steam_user.split(SteamConsts.STEAM_PROFILE_LINK)[1] return True
def generate_user_link(user): return u'<A HREF="' + SteamGiftsConsts.get_user_link( user) + u'">' + user + u'</A>'
def get_user_steam_id(user_name): html_content = WebUtils.get_html_page( SteamGiftsConsts.get_user_link(user_name)) steam_user = WebUtils.get_item_by_xpath( html_content, u'.//div[@class="sidebar__shortcut-inner-wrap"]/a/@href') return steam_user.split(SteamConsts.STEAM_PROFILE_LINK)[1]