Почему при парсинге Авито через Selenium дублируются карточки товара?

При парсинге Авито появляются дубликаты, заменяющие собой уникальные карточки с товаром, которые я хочу получить:

import time
from selenium import webdriver

url = 'https://www.avito.ru/brands/i357584534/items/all/odezhda_obuv_aksessuary?s=profile_search_show_all&sellerId=0ef4c451e53ee39b40d7a251d5721b08'

def parse(url):
    driver = webdriver.Firefox()
    driver.get(url)

    SCROLL_PAUSE_TIME = 0.5

    # Get scroll height
    last_height = driver.execute_script("return document.body.scrollHeight")
    while True:
        # Scroll down to bottom
        driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    # Wait to load page / use a better technique like `waitforpageload` etc., if possible
        time.sleep(3)
    # Calculate new scroll height and compare with last scroll height
        new_height = driver.execute_script("return document.body.scrollHeight")
        print(last_height, new_height)
        if new_height == last_height:
            break
        last_height = new_height

    # Save the page source to a file
    with open('pagecode.html', 'w', encoding='utf-8') as file:
        file.write(driver.page_source)

    # Ensure the driver quits
    driver.quit()

parse(url)

Дубликаты:

357  ww.avito.ru/sankt-peterburg/odezhda_o...          Спортивные шорты Nike оригинал  /40.img.avito.st/image/1/1.lfOD2baAORr1...  3987664265
494  ww.avito.ru/sankt-peterburg/odezhda_o...          Спортивные шорты Nike оригинал  /40.img.avito.st/image/1/1.lfOD2baAORr1...  3987664265
523  ww.avito.ru/sankt-peterburg/odezhda_o...              Ветровка Skechers оригинал  /30.img.avito.st/image/1/1.7TYgNLaAQd9W...  3987747821
274  ww.avito.ru/sankt-peterburg/odezhda_o...              Ветровка Skechers оригинал  /30.img.avito.st/image/1/1.7TYgNLaAQd9W...  3987747821
548  ww.avito.ru/sankt-peterburg/odezhda_o...       Лёгкие джинсы Hugo Boss оригинал»  /50.img.avito.st/image/1/1.xdabRbaAaT_t...  3988299460
..                                                 ...                                     ...                                                ...         ...
593  ww.avito.ru/sankt-peterburg/odezhda_o...  Винтажный шерстяной свитер Италия - XL  /30.img.avito.st/image/1/1.070WQLaAf1Rg...  4532244385
577  ww.avito.ru/sankt-peterburg/odezhda_o...         Винтажный норвежский свитер - S  /20.img.avito.st/image/1/1.S8UVSLaA5yxj...  4532302303
432  ww.avito.ru/sankt-peterburg/odezhda_o...         Винтажный норвежский свитер - S  /20.img.avito.st/image/1/1.S8UVSLaA5yxj...  4532302303
606  ww.avito.ru/sankt-peterburg/odezhda_o...              Брюки Dickies 874 оригинал  /80.img.avito.st/image/1/1.sQuQLraAHeLm...  4564069673
615  ww.avito.ru/sankt-peterburg/odezhda_o...              Брюки Dickies 874 оригинал  /80.img.avito.st/image/1/1.sQuQLraAHeLm...  4564069673

[297 rows x 4 columns]

Есть другой файл, который ищет элементы с помощью BeatifullSoup и сохраняет их в pandas.DataFrame, но мне кажется, что ошибка именно в парсере.


Ответы (0 шт):