Getting the best deals on Uber Eats (Part 2)

Disclaimer: The sole purpose of this article is to educate how to extract structured data from websites, how to use APIs and how developers or power-users can leverage these in order to perform periodic checks and trigger notifications on certain conditions.

In the first part of this article, we revealed the analysis process of how Uber Eats (webapp) works behind the scenes. If you didn’t follow it, click here to get more detailed information.

In this second part, we’ll be setting the Python environment locally so we can test and debug our scripts, disclosing all the code, and we’ll introduce you to the basics of Crontask app.

Setting up the local environment

We’re focused on a Python example, so let’s start off by setting up our local development environment - you can probably skip this part if you already executed a Python script on your machine. For now, we’ll just want to have installed a text editor in case we need to see the code, but you can for sure go ahead and install an IDE such as Visual Studio Code, PyCharm, Spyder.

Download and extract Linux or Windows embeddable package:

Open a terminal inside the extracted folder and download/install pip. You can check other forms of installation:

curl -o && python

Finally, go ahead and delete the file python39._ph

Please, just give me the code!

All the code examples or snippets from this blog will be entirely hosted in repository and specifically for the article you can check the main module here.

  1. On your machine, clone the repository and cd into it.
    git clone crontask-blog-examples && cd crontask-blog-examples
  2. Set the required environment variables. These are used in the helpers.mail module so that we can send the email notification after each execution. We’ll not go into the process of set up the env variables because this isn’t OS-agnostic. Feel free to Google it :)
  3. cd into the python directory, install the dependencies, launch the python module.
    cd python && pip install && python -m uber-eats-get-one-free-deals.main

By now, if everything goes according to plan, you should have an email on the inbox of MAIL_USER. All the above, was a mere simulation of what a development would look like. Once you feel confident and you’re ready to schedule it on Crontask, you just need to create an account on GitHub, BitBucket, etc., create your public repository and push the code.

How to use of Crontask in a nutshell

In this section we’ll explain how to create a task and set environment variables. First and foremost, please make sure that you’re already registered and signed-in. If that’s not the case then feel free to sign-up.

Create a new task

  1. Give it a name
  2. Set the repository:
  3. Select the Python execution agent
  4. Set the working directory path as: python
  5. Set the module name: uber-eats-get-one-free-deals.main
  6. Tick the dependency resolution checkbox
  7. Set your Cron expression to: 0 12,19 * * *

Set up the environment variables

  1. Click on the User icon and under Global Environment Variables, set your credentials for MAIL_USER and MAIL_PWD

Trigger a manual execution

  1. Click on the Run button

Again, if everything went well, the execution should result in a Status: Success and you should have an email on your inbox and this the task detail should look like the image below.

Crontask Basic Usage - Task detail screen on success

Now it’s time to forget! The script was scheduled to be executed at 12pm and 19pm according the timezone selected on your user preferences, and you’ll receive daily alerts on your inbox in case there are ongoing deals.

And that’s it. On the next article, we’ll cover the usage of the user space feature of the Crontask app. This becomes specially handy when we need to track changes between runs, like for example if the price of an asset drops relative to the previous price, we send an alert.