Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpage tracker #1320

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 29 additions & 0 deletions Python/Webpage_Update_Tracker/README.md
Original file line number Diff line number Diff line change
@@ -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)
27 changes: 27 additions & 0 deletions Python/Webpage_Update_Tracker/main.py
Original file line number Diff line number Diff line change
@@ -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!")