Skipping website queues ethically with #Python Website Scheduler

Skipping website queues ethically with #Python Website Scheduler

ยท

4 min read

I wanted to skip website queues that could be annoying to wait for in order to open at a certain time. So all I needed was a simple website scheduler that opens a website at a certain time. I know that there are loads of other options to try and disable JS or certain blocking. None of them actually worked for me. The concept was simple. Open a website at a certain time. Maybe, open many tabs seconds before the exact time to be even more accurate. I couldn't find this anywhere so I had to do it.

As a new Python developer it has been a simple yet confusing project. But, at the moment it simply works.

I only used the webbrowser library which doesn't need a web driver like Selenium. This makes it a great starting project for a beginner.

import webbrowser
import time

The tricky part was that I wanted it to be an independent app when a user gets asked to input data instead of having everything built-in or hard-coded. I had to ask specific questions to get specific answers to be used later.

while True:
    website = input("Enter the website without www. or .com. Just a word like google, facebook, etc: ")
    if website.isalpha():
        break
    else:
        print('The website name need to be word not a number. Please try again!')

I had to use many loops to sanitise code and make sure the variables are in a correct format as in int or str when needed.

Functions like isalpha (to check that the input is a string) and isnumeric (to check that the input is a number/intiger) where the best options after having a tantrum trying several other options.

I'd say sanitising code was the most confusing bit because you don't want the cide to break or keep going and that's it. I needed a loop to keep asking the right questions. Like here


# Constantly check inputs for the time are numbers  

while True:
    hours = input("Enter the hour like 02, 11, 23, etc: ")
    minutes = input("Enter the minutes like 02, 45, 00, etc: ")
    seconds = input("Enter the seconds like 02, 45, 00, etc: ")
    day = input("Enter the day as a number like 02, 22, 31, etc or if it's TODAY say yes to Skip: ")

# an option to skip adding the full day if it's the same day and just confirm. The is some number check sanitation

    if day == 'yes' or day == 'YES' or day == 'y' or day == 'Y':
        timeToOpen = f"{hours}:{minutes}:{seconds}" + time.strftime(' %x')
        if hours.isnumeric() and minutes.isnumeric() and seconds.isnumeric():
            break
        else:
            print('Hours, minutes, seconds, should be numbers. Please try again!')
            continue
    month = input("Enter the month as a number like 02 for February, 12 for December. etc: ")
    year = input("Enter the year as a 2 digit number like 21 for 2021: ")

# sanitise code by making sure the input is a number not anything else

    if hours.isnumeric() and minutes.isnumeric() and seconds.isnumeric() and day.isnumeric() and month.isnumeric() and year.isnumeric():
        timeToOpen = f"{hours}:{minutes}:{seconds} {month}/{day}/{year}"
        break
    else:
        print('Hours, minutes, seconds, day, month and year should be numbers. Please try again!')

This was me literally overthinking and trying to be ready for anything. (ps: I still think there is more to do here) It felt like I'm programming Alexa ๐Ÿ˜‚

It was a lovely project. The whole project is on my github.

github.com/Magdyz/websiteScheduler

The future of this project will contain a GUI hopefully. I think it will be kivy library. I will also add more functionality like pressing and skipping which is a challenge when thinking about a general app for all websites like this one. It will be a lot easier to hard code a Bot with Selenium where I search by id or xpath. I want it to work by user input. That's the plan anyway. The code still needs more small scale sanitisation like inputting a full website name instead of a word. I did this to make it quick and easy.

page = f"https://www.{website}.com"
today = time.strftime('%X %x')

It was a fun project and there is more to come. Keep an eye on my github and here.

ย