def parse():
    driver = webdriver.Chrome(executable_path=driver_path)
    driver.maximize_window()
    driver.get('https://divar.ir/s/tehran/buy-apartment')
    driver.implicitly_wait(5)
    driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/aside/div/div[1]/div[2]/div[1]').click()
    driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/aside/div/div[1]/div[2]/div[2]/div/button').click()
    component = driver.find_element(By.XPATH, '/html/body/div[2]/div/article/div/div/div/div')
    neighborhoods = []
    subtitles = []
    links = []
    for number in range(0, 29280, 650):
        driver.execute_script(f'arguments[0].scrollTop = {number}', component)
        sel = driver.page_source
        response = Selector(text=sel)
        for part in response.css('div.kt-control-row.kt-control-row--large.kt-control-row--clickable'):
            neighborhood = part.css('.kt-control-row__title::text').get()
            neighborhoods.append(neighborhood)
            subtitle = part.css('.kt-base-row__description.kt-body--sm::text').get()
            subtitles.append(subtitle)
            link = part.css('.kt-control-row__title').attrib['href']
            links.append(link)
            print(type(links))
    counter = 1
    set_links = set(links)
    for element in set_links:
        counter += 1
        if (counter <= 5):
            continue
        neighborhood_link = ('https://divar.ir' + element)
        parse_neighborhood(neighborhood_link)
def parse():
    driver = webdriver.Chrome(executable_path=driver_path)
    driver.maximize_window()
    driver.get('https://divar.ir/s/tehran/buy-apartment')
    driver.implicitly_wait(5)
    driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/aside/div/div[1]/div[2]/div[1]').click()
    driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/aside/div/div[1]/div[2]/div[2]/div/button').click()
    component = driver.find_element(By.XPATH, '/html/body/div[2]/div/article/div/div/div/div')
    neighborhoods = []
    subtitles = []
    links = []
    for number in range(0, 29280, 650):
        driver.execute_script(f'arguments[0].scrollTop = {number}', component)
        sel = driver.page_source
        response = Selector(text=sel)
        for part in response.css('div.kt-control-row.kt-control-row--large.kt-control-row--clickable'):
            neighborhood = part.css('.kt-control-row__title::text').get()
            neighborhoods.append(neighborhood)
            subtitle = part.css('.kt-base-row__description.kt-body--sm::text').get()
            subtitles.append(subtitle)
            link = part.css('.kt-control-row__title').attrib['href']
            links.append(link)
            print(type(links))
    counter = 1
    set_links = set(links)
    for element in set_links:
        counter += 1
        if (counter <= 5):
            continue
        neighborhood_link = ('https://divar.ir' + element)
        parse_neighborhood(neighborhood_link)