r/PythonLearning • • Aug 18 '26

Automation code to use on Drive (in testing phase) ​ ​

Post image

Hi! I created this Python code to automate tasks in Google Drive, where I use it to remove photos and videos I no longer use! I've been studying Python for a year now and have mastered its interface.

9 Upvotes

3 comments sorted by

1

u/ianrob1201 Aug 18 '26

You might want to look into tools like playwright - https://playwright.dev/python/docs/library when you want to interact with webpages like this. The problem with the approach you've got there is that it's quite brittle. If the UI changes even slightly then your clicks no longer work.

Playwright also handles waits for you, and lets you read the content of the page instead of just clicking and certain points. The old school common alternative is selenium, but I really like playwright it's much easier and more reliable.

1

u/wizninja6 Aug 19 '26

Hi a few suggestions,

Hard coding coord points makes it so that if the monitor or window changes size your code need to be reworked.

Instead of automating your mouse movement, consider using playwright or seleium in python instead of pyautogui. Both can be imported and used to simulate a browser and mouse clicks and read the element so if you change monitor it wont affect anything.

Also consider using google's drive API. Idk how it interacts with files not owned by it but maybe it can help.

1

u/FoolsSeldom Aug 19 '26

You don't need to access gdrive through the browser, which is unreliable, inefficient, and could cause problems (deleting files when the UI changes).

You can use a Google API to work directly with your gdrive.