RE: Python Selenium Help 02-10-2021, 12:54 PM
#2
(02-10-2021, 03:40 AM)Einsatzgruppe Wrote: so long story short is there a way i can code it to auto clean google-cookie file out itself?? Or is that impossible ? from the basic research i did everyone just said introduce a sleep witch yes in the short run it will have an impact but the file will still fill up just will take longer and ill be stuck in the same boat
Hello. Since you do not want to use time.sleep() I would suggest something along the lines of:
Code:
from os import remove
try:
remove(path_to_file)
except OSError:
passThis is what I get when trying to delete a non existent file:
Code:
>>> from os import remove
>>> remove("12345.txt")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '12345.txt'
>>> try:
... remove("12345.txt")
... except OSError:
... pass
...
>>>Using the try and except is necessary is you do not want to wait for the file to be created or if you do not know how long it takes to be created after deleting.
Code:
_______ _ _________
\ \ | | / /
| | _____ ____| | | ____/ _____ _____ _____ _____
| | |/ _ \/ | \____ |/ \/ \/ ___\/ _ \
| | __/| | |/ | | | | \ \__ | __/
/_______/\_____/\____|_/________/| ____/\_____|_\____/\_____/
| |
|_/
BTC Address: bc1qds8uqnt4ga0zn9ftrm45cq9u9hfct0qluqes5a
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)