def get_recent_matches(session, init_url, from_timestamp, limit):
    """Get recently played user matches."""
    if not from_timestamp:
        from_timestamp = datetime.datetime.now() - datetime.timedelta(days=1)
    matches = []
    page_id = 0
    done = False
    while not done and page_id < MAX_MATCH_PAGE_ID:
        url = '{}/{}'.format(init_url, page_id)
        parsed = make_scrape_request(session, url)
        for row in parsed.find('table').find_all('tr')[1:]:
            cols = row.find_all('td')
            played_at = dateparser.parse(cols[2].text)
            match_id = int(cols[5].find('a').text[1:])
            has_rec = cols[6].find('a').find('img')
            if played_at < from_timestamp or (limit and len(matches) == limit):
                done = True
                break
            if not has_rec:
                continue
            matches.append({
                'timestamp': played_at,
                'match_id': match_id
            })
        if not matches:
            break
        page_id += 1
    return matches
def get_recent_matches ( session , init_url , from_timestamp , limit ) : if not from_timestamp : from_timestamp = datetime . datetime . now ( ) - datetime . timedelta ( days = 1 ) matches = [ ] page_id = 0 done = False while not done and page_id < MAX_MATCH_PAGE_ID : url = '{}/{}' . format ( init_url , page_id ) parsed = make_scrape_request ( session , url ) for row in parsed . find ( 'table' ) . find_all ( 'tr' ) [ 1 : ] : cols = row . find_all ( 'td' ) played_at = dateparser . parse ( cols [ 2 ] . text ) match_id = int ( cols [ 5 ] . find ( 'a' ) . text [ 1 : ] ) has_rec = cols [ 6 ] . find ( 'a' ) . find ( 'img' ) if played_at < from_timestamp or ( limit and len ( matches ) == limit ) : done = True break if not has_rec : continue matches . append ( { 'timestamp' : played_at , 'match_id' : match_id } ) if not matches : break page_id += 1 return matches
Get recently played user matches.