-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMonitor.py
52 lines (44 loc) · 1.3 KB
/
Monitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#Made by MarbitXD
#Posted on Github : https://github.com/MarbitXD/SimpleWebPageMonitorWithDiscordNotifi
import discord
import asyncio
from discord.ext import commands, tasks
from asyncio import coroutine
import urllib
import urllib.request
import time
import os
from selenium import webdriver
from dhooks import Webhook, Embed
url = str("YOUR WEBSITE")
hook = Webhook('YOUR DISCORD WEBHOOK')
driver = webdriver.Chrome('chromedriver.exe')
bot = commands.Bot(command_prefix="!")
client = discord.Client()
@client.event
async def on_ready():
print('Bot is ready!')
update_check.start()
async def on_webUpdate():
embed = Embed(color=14177041,)
embed.set_author("Change")
hook.send(embed=embed)
quit()
@tasks.loop()
async def update_check():
try:
a = urllib.request.urlopen(url)
await asyncio.sleep(15)
webpage = a.read().decode('utf-8')
await asyncio.sleep(30)
ab = urllib.request.urlopen(url)
await asyncio.sleep(15)
webpage2 = ab.read().decode('utf-8')
if (webpage2 != webpage) :
print('update')
asyncio.create_task(on_webUpdate())
else:
print('not_changed')
except:
print('error')
client.run('YOUR DISCORD TOKEN')