You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I called get_user_pins on users with large numbers of pins (>5k) it seems to get the first 10+ pages and then stops short. This is the function I'm using.
defget_pins(username, page_size=250, max_pages=None):
pages_processed=0user=pinterest.get_user_overview(username)
total_num_pins=user.get("pin_count")
total_pages= (
total_num_pins+page_size-1
) //page_size# Ensuring all pins are counted even if the last page is not fullpbar=tqdm(
total=total_pages, desc="Pages Processed", position=1, leave=False
) # Set up the main progress bar for pages# Fetch the initial batch of pinspin_batch=pinterest.get_user_pins(username, page_size=page_size, reset_bookmark=True)
whilepin_batch: # Continue until an empty batch is returnedpins= {} # Initialize or reset the pins dictionary for the new batchforpininpin_batch:
try:
pin_id=int(pin.get("id"))
pins[pin_id] =pinexceptExceptionase:
continue# Skip any pins that cause errorspages_processed+=1pbar.update(1) # Update the progress bar for each batch processed# Fetch the next batch of pinspin_batch=pinterest.get_user_pins(username, page_size=page_size)
if (max_pagesisnotNone) and (pages_processed>max_pages):
breakpbar.close() # Close the progress bar when no more pins are returnedreturnpin_batch
The text was updated successfully, but these errors were encountered:
When I called get_user_pins on users with large numbers of pins (>5k) it seems to get the first 10+ pages and then stops short. This is the function I'm using.
The text was updated successfully, but these errors were encountered: