-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
29 lines (20 loc) · 911 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
import json
import requests
from data import *
from url import Url
for url_to_check in urls_to_check:
for i, url in enumerate( url_to_check['urls'] ):
print(url)
for j, child in enumerate( Url(url).get_children() ):
print(f'{i}.{j} - Checking {child}')
if child.response_status() != 200 or j==3:
body = \
f'You have a broken link at {url}\n' + \
f'- Link: {child}\n' + \
'\n\n' + \
'This message was automatically created by <https://github.com/matheusvanzan/broken-links-monitor|broken-links-monitor>'
response = requests.post(
url_to_check['channel'],
json.dumps({ 'text': body })
)
print(response)