From the site I get data through the variable name_elem_site . Data - 1 word. After some time, it is replaced by another. Maybe even 10 words per second or more. Those. instead of a variable it can be: Word1, Word2, Word3, .., Word2, Word3, .., WordN.
It is necessary to record this data in a list (?) And place it in a log file1. Then, read this log file and count the number of repetitions with output to the console and write to another log file2.
with open("logfile.txt", "w") as log: while True: name_elem_site = text_element_by_class_name(driver, "texttexttext") a = [] for word in name_elem_site: # хз какое условие, количество слов не известно, но явно не больше 50 a.append(str(name_elem_site)) print(a) log.write(str(name_elem_site) + "\n") log.flush() Without a counter, such a code, but of course there is no part and it is not correct, because in the log file for 100,500 repetitions of the current word on the site.