Vibe scripting with AI and Python
- Authors

- Name
- Matt Morris
One of the greatest benefits of AI is its ability to help you write code, which doesn't just include large applications. It can also help you write scripts for smaller tasks, a great way for someone new to programming to get started and create something useful quickly.
In this post, I share a few examples of how I use AI to help me write Python scripts for a variety of purposes that could be approachable for anyone willing to take a few steps to set up a development environment and install any necessary packages (AI can help with that as well).
These are the kinds of capabilities that can be used on their own, extended to agents, or included in an automated workflow.
Examples
Caption file generator script
I work with video a lot and we always need caption files for the videos we produce. These are generally available but sometimes not (or they are available in a different format than we need).
Previously this would have required finding a team that can convert the file or scrambling to find a tool that can do it for free (usually with AdWare). Now, it's incredibly easy to use AI to generate a script for you that can create a caption file in whatever format you need. You just need a Python development environment set up and the necessary packages installed.
The script uses the OpenAI Whisper model model to transcribe the audio from a video file and output it as a caption file in the desired format.
You run it from the command line, passing in the video file as an argument, and it will generate a caption file in the same directory.
Example Usage
I used the viral "I'm not a cat" video as the input for this example:
Here's the script output in SRT format:
Web scraper script
I work with web data a lot and sometimes need to scrape data from websites. This can be a tedious task, especially when the website is dynamic and requires interaction to load all the data.
This example uses Playwright to scrape the Apple Retail Success Stories page. It connects to a running instance of Chrome with remote debugging enabled, navigates to the page, scrolls to load all the content, and extracts the relevant information.
Example output
You could adapt this to output to a spreadsheet or whatever format you need to, but for this example, I just printed the results to the console. The output is a list of dictionaries, each containing the title, description, URL, and image (if available) of each unique story found on the page.
The script can also be adapted to scrape other pages or websites by changing the BASE_URL and adjusting the selectors as needed.
Semantic search script
Python is excellent at processing text data, and AI can help you do it even better. One of the most useful applications of AI is semantic search, which allows you to search for information based on meaning rather than just keywords.
The script I generated uses the sentence-transformers library to create a semantic search mini-engine that can index documents and perform semantic queries against them. The script can load documents from a folder, extract text from various file formats (plain text, markdown, HTML, Word, PDF, PowerPoint, Excel), and build embeddings for the documents using a transformer model. It also provides a fallback option using TF-IDF and SVD if the transformer model is not available.
Example output
I used AI to create some placeholder documents and then ran the semantic search script against them. Here's an example of what the output looks like when you run a query: