} # Grabbing most used Pokemon online ranked 1 - 25 according to Pikalytics most_popular = format_data(soup.find(id='min_list'), num_spaces=2) for i in range(int(len(most_popular)/2)): temp_list = [most_popular[i][0], most_popular[i + 1][0]] most_popular[i] = temp_list del (most_popular[i + 1]) # Path needs to be specified by the user path = '' # For each Pokemon in the top 25, creates a CSV file for common moves, teammates, items, abilities, and ev spreads # Checks to make sure the directories exist, and create new ones if they don't for i in range(len(most_popular)): directory = path + most_popular[i][0].title() for key, value in id_dict.items(): URL_pikalytics = "https://pikalytics.com/pokedex/ss/" + most_popular[i][0].lower() pikalytics_page = requests.get(URL_pikalytics) soup = BeautifulSoup(pikalytics_page.text, 'html.parser') data = format_data(soup.find(id=key), value[0], value[1], value[2], value[3]) filepath = directory + '/' + most_popular[i][0] + '_' + value[4][0] + '.csv' file = CSV(data, filepath) if not os.path.exists(directory): os.makedirs(directory) else: if not os.path.exists(filepath): file.create_file(value[4][1:len(value[4])]) file.csv_write()