But just so if anyone has this problem, this is how I solved it, using browser automation. So the Worker's Browser Rendering API basically allows you to, you know, run automation within your browser. You could do things like, you know, navigate to a specific website, take a screenshot of the website, create a PDF out of the website, and so on.
So for my specific use case, instead of going to the website on Wednesday at 12 p.m. every single week, I wanted to automate this process, right? I wanted to allow my browser do that for me, without me having to do it myself. So what did I do? I essentially wrote the browser rendering worker that would navigate to the specific website at the specific time. Honestly, I just would run this every single time, just because I wanted to be sure that I could find an apartment, right? So what this does is, it navigates to the websites, takes a screenshot of the specific availability page. So if there is an availability at a time, the website is going to tell me that, oh, you're lucky. There is currently an apartment available. In fact, at this specific time, there was three different apartments available. So I was able to, you know, go to the website and pay for the apartment that I wanted to do.
Of course, this is just a cool example that, you know, browser automation can help you with. There's so much more that you can do. For example, with this demo, I could as well go one step further to make a Chrome job that I would make this worker run at a specific day every week. Or I could also add like email automation where if there's an apartment, instead of like returning the value of the apartment to the website, I could send myself an email and I would be automatically informed of the availability, right? So that's an actual use case that I think browser automation can help with.
So with that, I want to talk about underlying technology within that, you know, setup I just showed you, which is Cloudflare Workers. If you're not familiar, Cloudflare Workers is a serverless environment that allows you to create new applications or augment existing ones with, you know, languages you're already used to like JavaScript, TypeScript, or even Python. So this is an example Cloudflare Worker. Basically what this does is it's returning a string or an array of conference data, in this case, GSNation, and I'm returning that to my browser. It's essentially written in JavaScript. This example I'm showing you, but you can as well write it in TypeScript or in Python if you want.
Now moving forward, just a few slides. Yeah. Browser rendering API is one of the services that we offer in the Cloudflare developer platform. Essentially what this is, is it allows you as a developer to control and interact with a headless browser instance. And from that, you can then create automatic flows, for example, navigate to a website, take a screenshot, and so much more. And the underlying technology here, if you ever explored the topic of browser automation, you possibly have heard of Puppeteer. So Puppeteer is a Node.js library from Chrome DevTools team. It essentially provides an abstraction of the DevTools protocol to help you control Chrome or Chromium. Now the worker's browser rendering API is a fork of Puppeteer.
Comments