Combining Zapier triggers with Selenium automation

I’ve got some Python scripts that use Selenium for browser automation on websites without APIs. Now I want to make them run based on triggers instead of manually. I thought about adding time-based checks to the scripts but I’m not keen on leaving a computer running all the time for this.

Is there a way to use Zapier’s trigger system with Selenium? Or maybe another method to achieve something similar? I’m looking for a solution that doesn’t require constant script execution.

Here’s a basic example of what I’m working with:

from selenium import webdriver

def automate_task():
    driver = webdriver.Chrome()
    driver.get('https://example.com')
    # Perform actions
    driver.find_element_by_id('some_button').click()
    # More automation steps
    driver.quit()

# How can I make this run based on external triggers?

Any ideas on how to set this up with Zapier or an alternative trigger system? Thanks for your help!

hey there Tom42Gamer! hav u considered using AWS Lambda? it can run ur selenium scripts on-demand without keeping a machine on 24/7. u could set up an API Gateway to trigger the Lambda function, then use Zapier to hit that API endpoint when ur trigger conditions r met. might be worth checkin out!

Integrating Zapier with Selenium directly isn’t straightforward, but you have a few options to achieve what you’re after. One approach is to use a cloud-based solution like AWS Lambda or Google Cloud Functions. These services can run your Selenium scripts on-demand, triggered by Zapier workflows.

Alternatively, you could set up a small server (like a Raspberry Pi) that runs a lightweight web server. Your Selenium script could be exposed as an endpoint, which Zapier can then call via a webhook when your trigger conditions are met.

Both methods allow you to keep your current Selenium setup while adding the flexibility of Zapier’s extensive trigger options. The choice depends on your comfort level with cloud services versus managing your own hardware.

I encountered a similar challenge and found that a combination of Heroku and a Redis Queue worked well. I deployed the Selenium script on Heroku, as its free tier is suitable for small projects, and then configured a Redis Queue to manage tasks. I also built a simple Flask application that exposes an endpoint; once this endpoint is called, it adds a job to the queue. Zapier triggers this endpoint when the specified conditions are met, and a worker on Heroku processes the job by running the Selenium script. This solution requires some initial setup but proves robust and efficient once operational.