В файл записывается только одно имя (последнее), как мне записать все имена?
import time
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import WebDriverException
import csv
browser = webdriver.Chrome()
browser.set_window_size(1024, 600)
browser.maximize_window()
try:
browser.get(f'https://telega.in/catalog')
except WebDriverException:
print("page down")
m = 0
sleep(4)
n = 1
for i in range(1, 4, 1):
li = 8000
browser.execute_script(f"window.scrollTo(0, {li});");
sleep(5)
button = browser.find_element(By.XPATH, '/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[2]/div[2]/div[1]').click()
li = li + 8000
if i == 3:
while n < 140:
Name = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[1]/div[2]/div[1]/span')
Description = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[1]/div[2]/div[2]')
Subscribers = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[2]/div[1]/div[1]/span[2]')
er = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[2]/div[1]/div[4]/span[2]')
Views = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[2]/div[1]/div[3]/span[2]')
Categories = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[1]/div[2]/div[3]')
Price_for_one_number_of_placements = browser.find_element(By.XPATH, f'/html/body/div[16]/div[2]/div/div[2]/div/div[2]/div[1]/div[{n}]/div[3]/div[1]/div[3]/div[1]')
print('NAME: ', Name.text)
with open("epicstars_inst.csv", mode="w", encoding='utf-8') as w_file:
file_writer = csv.writer(w_file, delimiter=",", lineterminator="\r")
file_writer.writerow(["Name"])
file_writer.writerows(zip([Name.text]))
n = n + 1