- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create a Website Alarm Using Python
In this section we will see how to create the website alarm system using Python.
Problem Statement
Open a website URL on the browser by taking a website URL and time. When the system time reaches the specified time, the webpage will be opened.
We can store different web pages in our bookmark sections. Sometimes we need to open some web pages every day on a specific time to do some work. For that purpose, we can set this type of website alarm to do the work.
In this case we are using some standard library modules like sys, web browser and time.
Steps to open web pages on a specific time
- Take the URL which will be opened.
- Take the time to open the webpage on that time.
- Check whether the current time is matched with the specified time or not.
- If the time matches, open the webpage. Otherwise wait for one second.
- Repeat the step 3 in each second until the time matches.
- End the process
Example Code
import time import webbrowser import sys def web_alarm(url, alarm_time): current_time = time.strftime('%I:%M:%S') while(current_time != alarm_time): #repeatedly check for current time and the alarm time print('Current time is: ' + current_time) current_time = time.strftime('%I:%M:%S') time.sleep(1) #wait for one second if current_time == alarm_time: #when the time matches, open the browser print('Opening the ' + url + ' now...') webbrowser.open(url) web_alarm(sys.argv[1], sys.argv[2]) #Set the alarm using url and time
Output
$ python3 397.Website_Alarm.py https://www.tutorialspoint.com/ 02:01:00 Current time is: 02:00:46 Current time is: 02:00:46 Current time is: 02:00:47 Current time is: 02:00:48 Current time is: 02:00:49 Current time is: 02:00:50 Current time is: 02:00:51 Current time is: 02:00:52 Current time is: 02:00:53 Current time is: 02:00:54 Current time is: 02:00:55 Current time is: 02:00:56 Current time is: 02:00:57 Current time is: 02:00:58 Current time is: 02:00:59 Opening the https://www.tutorialspoint.com/ now... $

- Related Articles
- How to create a website without using HTML?
- Website Blocker Using Python
- How to create an FAQ section of a website using JavaScript?
- How to create a favicon for your website?
- How to create a Phishing page of a website?
- How can I parse a website using Selenium and Beautifulsoup in python?
- How to create a responsive website with Bootstrap 4?
- What is a Fire Alarm?
- How to Build your own website using Django in Python
- How to create Favicon for your website?
- How to start service using Alarm Manager in android?
- Can we build a website from python?
- Create a stopwatch using python
- How to create photography website in a minute or less 2
- What is Fire Alarm?

Advertisements