From 634bc57d05e9396554dd62322ef729da23f50551 Mon Sep 17 00:00:00 2001 From: Rishav-12 Date: Sun, 6 Mar 2022 14:59:46 +0000 Subject: [PATCH 1/2] add webpage update tracking script --- Python/Webpage_Update_Tracker/README.md | 29 +++++++++++++++++++++++++ Python/Webpage_Update_Tracker/main.py | 27 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Python/Webpage_Update_Tracker/README.md create mode 100644 Python/Webpage_Update_Tracker/main.py diff --git a/Python/Webpage_Update_Tracker/README.md b/Python/Webpage_Update_Tracker/README.md new file mode 100644 index 000000000..684664ada --- /dev/null +++ b/Python/Webpage_Update_Tracker/README.md @@ -0,0 +1,29 @@ +# Webpage_Update_Tracker + +A script that helps the user track any updates to a webpage + +It takes a snapshot of the webpage and saves it with a filename corresponding to the date and time when it was taken + +## Setup instructions + +- Install geckodriver from https://github.com/mozilla/geckodriver/releases/tag/v0.30.0 + +- Extract the geckodriver executable and add it to PATH + +- You also need selenium, which is a third party Python library. So + + ```bash + pip install selenium + ``` + +- Run the script using `python3 main.py`. It will prompt the user to enter the link to the specific webpage. Do that and output image will be generated. + +## Output + +[How to run the code](https://imgur.com/a/4CRjOxt) + +[Example output](https://imgur.com/a/IAtma9r) + +## Author + +[Rishav Mitra](https://github.com/Rishav-12) diff --git a/Python/Webpage_Update_Tracker/main.py b/Python/Webpage_Update_Tracker/main.py new file mode 100644 index 000000000..c41d3dc92 --- /dev/null +++ b/Python/Webpage_Update_Tracker/main.py @@ -0,0 +1,27 @@ +# standard library +from datetime import datetime +from time import sleep + +# installed library +from selenium import webdriver + +# initialize Firefox webdriver +options = webdriver.FirefoxOptions() +options.headless = True +driver = webdriver.Firefox(options=options) + +# get the current date and time in proper format +# to be included in the filename +now = datetime.now() +now_string = now.strftime("%d-%m-%Y_%H:%M:%S") + +page = input("Enter the link of the webpage you want to snapshot:\n") + +# access the page +driver.get(page) +sleep(1) + +# take screenshot, save with proper filename +driver.get_screenshot_as_file(f"screenshot_{now_string}.png") +driver.quit() +print("Snapshot generated!") From 49cdb10e85d8e2d8b1a42944e74f5d0d6b2223ca Mon Sep 17 00:00:00 2001 From: Rishav-12 Date: Sun, 6 Mar 2022 15:15:00 +0000 Subject: [PATCH 2/2] add webpage update tracker to Python README --- Python/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/README.md b/Python/README.md index 27f88eb5b..62486cadd 100644 --- a/Python/README.md +++ b/Python/README.md @@ -188,6 +188,7 @@ - [Watermark_Images](./Watermark_Images) - [Watermark_It](./Watermark_It) - [Weather_using_OpenWeatherMap](./Weather_using_OpenWeatherMap) +- [Webpage_Update_Tracker](./Webpage_Update_Tracker) - [Website_Blocker](./Website_Blocker) - [Website_Cloner](./Website_Cloner) - [WhatsApp_COVID-19_Bot](./WhatsApp_COVID-19_Bot)