<jupyter_start><jupyter_text>Old Code<jupyter_code>XPATH_COUNTRY_TABLE = '//*[@id="primaryInner"]/div/div[1]'
XPATH_COUNTRY_NAME = '//*[@id="primary"]/h1/span'
for country_path in country_url_list:
    page_num = 0
    while True:
        driver.get(country_path + '?page=' + str(page_num))
        division = driver.find_element_by_xpath(XPATH_COUNTRY_TABLE) # 빼면 안됨
        name_list = division.find_elements_by_tag_name('li') # List형
        image_url_list = division.find_elements_by_tag_name('img') # List형
        img_folder_path = './brands_of_the_world/' + division.text + '_company_logo/'

        company_name_list = []
        for name in name_list:
            company_name_list.append(name.text)

        # if company_name_list == ['« first', '‹ previous', '1', '2']:
        if len(image_url_list) == 0:
            break
        page_num +=1

        i = 0
        for image_url in image_url_list:
            try:
                with urllib.request.urlopen(image_url.get_attribute('src')) as f:
                    with open(img_folder_path + company_name_list[i] +'.jpg','wb') as h:
                        image = f.read()
                        h.write(image)
            except Exception as e:
                print(e)
            i+=1<jupyter_output><jupyter_text>New Code (joowon)<jupyter_code>try:
    XPATH_COUNTRY_TABLE = '//*[@id="primaryInner"]/div/div[1]'
    XPATH_COUNTRY_NAME = '//*[@id="primary"]/h1/span'
    COUNTRY_NUMBER = 0
    for country_path in notebook.tqdm(country_url_list, desc='iterate range 100'):
        driver.get(f'{country_path}?page=0')
        driver.implicitly_wait(2)
        country_name = driver.find_element_by_xpath(XPATH_COUNTRY_NAME)
        img_folder_path = './brands_of_the_world/' + country_name.text + '_company_logo/'
        COUNTRY_NUMBER +=1
        print('%d 번째 나라 : [%s]' %(COUNTRY_NUMBER,country_name.text))
        if os.path.isdir(img_folder_path) is True:
            continue
        os.makedirs(img_folder_path, exist_ok=True)

        page_num = 0
        while True:
            # driver.get(country_path + '?page=' + str(page_num))
            driver.get(f'{country_path}?page={page_num}') #f string 
            
            division = driver.find_element_by_xpath(XPATH_COUNTRY_TABLE) # 빼면 안됨
            name_list = division.find_elements_by_tag_name('li') # List형
            image_url_list = division.find_elements_by_tag_name('img') # List형

            if len(image_url_list) == 0: # ['« first', '‹ previous', '1', '2']
                break

            for i, image_url in enumerate(image_url_list):
                try:
                    with urllib.request.urlopen(image_url.get_attribute('src')) as f:
                        with open(img_folder_path + name_list[i].text +'.jpg','wb') as h:
                            image = f.read()
                            h.write(image)
                except Exception as e:
                    print(e)
            
            print('Images of page number[%d] had saved completely!' %(page_num))
            page_num +=1
            
except Exception as e:
    print(e)
except KeyboardInterrupt:
    print("KeyboardInterrupt")
except:
    print('Other error')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12066831683168316, 'fraction_numerical': 0.007116336633663367, 'mean_word_length': 2.245983935742972, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '503350', 'license': 'Unlicense', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1080, 'n_words': 188, 'path': 'status_not_saved.ipynb', 'repo_name': 'jaewook94/data-crawling-project', 'size': '3232'}