'How it's logically possible to exit this loop while gathering data

here's the API for refence: https://github.com/JeremySkalla/pysmashgg/tree/3b04a4b2d83bbfe765c519ac37c437f478984742

There is a function in the API event_by_game_size returns a list of tournaments with metadata. The list can be different lengths and page numbers. The max page number is 313 after this it will return None. I have no idea how much data there is. Could return 10 pages, 5 pages then 313.

If I exit by the ending time and date, I could miss data because another page wasn't accounted for. My solution now: waiting for the repeat then manually deleting the last writes to the file.

How do I end this loop? I already gathered the data I needed but was curious if there was a way to logically end the loop?

    while num_pages != 0:
        try:
            tournaments = smash.tournament_show_event_by_game_size_dated
(entrants_limit, game_id, year_start, year_end, page)
        except:
            year_start = continue_date
            page = 0
            num_pages = get_num_page_tourn
(entrants_limit, game_id, year_start, year_end, page)

see comment for a little more information.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source