Login Register


Python Selenium Help filter_list
Author
Message
RE: Python Selenium Help #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: pass

This 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






Messages In This Thread
Python Selenium Help - by Einsatzgruppe - 02-10-2021, 03:40 AM
RE: Python Selenium Help - by DedSpace - 02-10-2021, 12:54 PM
RE: Python Selenium Help - by Einsatzgruppe - 02-10-2021, 01:23 PM
RE: Python Selenium Help - by DedSpace - 02-10-2021, 06:49 PM
RE: Python Selenium Help - by Einsatzgruppe - 02-11-2021, 11:46 PM
RE: Python Selenium Help - by DedSpace - 02-12-2021, 07:42 PM
RE: Python Selenium Help - by valentine - 03-12-2022, 07:05 PM
RE: Python Selenium Help - by mothered - 03-13-2022, 01:31 AM



Users browsing this thread: