-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
42 lines (35 loc) · 844 Bytes
/
main.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
import requests
import os
import time
from bs4 import BeautifulSoup
from keep_alive import keep_alive
webhook = os.getenv('WEBHOOK')
url = os.getenv('URL')
searchTerm = os.getenv('SEARCHTERM')
data = {
"content" : "Likely taking patients!",
"username" : "Doctor Bot-topus"
}
data["embeds"] = [
{
"description" : url,
"title" : "Link to page"
}
]
def pingDiscord():
result = requests.post(webhook, json = data)
try:
result.raise_for_status()
except requests.exceptions.HTTPError as err:
print(err)
else:
print("Payload delivered successfully, code {}.".format(result.status_code))
def checkDoctor():
html = requests.get(url).content
soup = BeautifulSoup(html, features="html5lib")
if searchTerm not in soup.prettify():
pingDiscord()
keep_alive()
while True:
checkDoctor()
time.sleep(60)