Created
April 29, 2023 15:16
-
-
Save cyb3rsalih/199565bbc8cd63e83c8e3ac9217ca8e7 to your computer and use it in GitHub Desktop.
notify when site changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
import argparse | |
parser = argparse.ArgumentParser(description='Site kontrol uygulaması') | |
parser.add_argument('--url', required=True, type=str, help='Kontrol edilecek URL') | |
parser.add_argument('--interval', required=True, type=int, help='Kontrol aralığı (dakika cinsinden)') | |
parser.add_argument('--notify', required=True, type=str, help='Bildirim yapılacak URL') | |
parser.add_argument('--post', type=str, help='POST isteği yapılacak veri') | |
args = parser.parse_args() | |
previous_content = '' | |
while True: | |
response = requests.get(args.url) | |
if response.status_code != 200: | |
print(f'Siteye ulaşılamadı. Durum kodu: {response.status_code}') | |
else: | |
content = response.text | |
if content != previous_content: | |
print('Site içeriği değişti. Bildirim gönderiliyor...') | |
previous_content = content | |
if args.post: | |
requests.post(args.notify, data=args.post) | |
else: | |
requests.get(args.notify) | |
time.sleep(args.interval * 60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment