Spaces:
Sleeping
Sleeping
raannakasturi
commited on
Commit
•
9a2e6d0
1
Parent(s):
bd0aee5
Update main.py
Browse files
main.py
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
import tldextract
|
2 |
-
from getStatus import getStatus
|
3 |
-
from getScreenshot import getScreenshot
|
4 |
-
from saveDataSendMail import saveDataSendMail
|
5 |
-
import subprocess
|
6 |
-
import sys
|
7 |
-
|
8 |
-
def cleanURL(inputURL):
|
9 |
-
url = tldextract.extract(inputURL)
|
10 |
-
if url.subdomain == "":
|
11 |
-
domain = url.domain + "." + url.suffix
|
12 |
-
URL = "https://" + domain
|
13 |
-
else:
|
14 |
-
domain = url.subdomain + "." + url.domain + "." + url.suffix
|
15 |
-
URL = "https://" + domain
|
16 |
-
return domain, URL
|
17 |
-
|
18 |
-
def getData(url, email):
|
19 |
-
domain, URL = cleanURL(url)
|
20 |
-
code, status, webStatus, moreDetails = getStatus(URL)
|
21 |
-
if code.startswith("2"):
|
22 |
-
img, imgurl = getScreenshot(URL)
|
23 |
-
else:
|
24 |
-
img = "1366-768.png"
|
25 |
-
imgurl = "Website is down. No screenshot available."
|
26 |
-
email, downcount
|
27 |
-
return domain, URL, code, status, webStatus, moreDetails, img, imgurl, email, downcount
|
28 |
-
|
29 |
-
def installGC():
|
30 |
-
OS = sys.platform
|
31 |
-
if OS == 'linux':
|
32 |
-
subprocess.run(['apt-get', 'update'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
33 |
-
subprocess.run(['apt-get', 'install', '-y', 'wget', 'unzip'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
34 |
-
subprocess.run(['wget', 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
35 |
-
subprocess.run(['apt-get', 'install', '-y', './google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
36 |
-
subprocess.run(['rm', 'google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
37 |
-
subprocess.run(['apt-get', 'clean'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
38 |
-
else:
|
39 |
-
subprocess.run(['powershell', '-command', 'winget', 'install', 'Google.Chrome', '--force'])
|
40 |
print("Chrome installed!")
|
|
|
1 |
+
import tldextract
|
2 |
+
from getStatus import getStatus
|
3 |
+
from getScreenshot import getScreenshot
|
4 |
+
from saveDataSendMail import saveDataSendMail
|
5 |
+
import subprocess
|
6 |
+
import sys
|
7 |
+
|
8 |
+
def cleanURL(inputURL):
|
9 |
+
url = tldextract.extract(inputURL)
|
10 |
+
if url.subdomain == "":
|
11 |
+
domain = url.domain + "." + url.suffix
|
12 |
+
URL = "https://" + domain
|
13 |
+
else:
|
14 |
+
domain = url.subdomain + "." + url.domain + "." + url.suffix
|
15 |
+
URL = "https://" + domain
|
16 |
+
return domain, URL
|
17 |
+
|
18 |
+
def getData(url, email):
|
19 |
+
domain, URL = cleanURL(url)
|
20 |
+
code, status, webStatus, moreDetails = getStatus(URL)
|
21 |
+
if code.startswith("2"):
|
22 |
+
img, imgurl = getScreenshot(URL)
|
23 |
+
else:
|
24 |
+
img = "1366-768.png"
|
25 |
+
imgurl = "Website is down. No screenshot available."
|
26 |
+
email, downcount = saveDataSendMail(URL, email)
|
27 |
+
return domain, URL, code, status, webStatus, moreDetails, img, imgurl, email, downcount
|
28 |
+
|
29 |
+
def installGC():
|
30 |
+
OS = sys.platform
|
31 |
+
if OS == 'linux':
|
32 |
+
subprocess.run(['apt-get', 'update'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
33 |
+
subprocess.run(['apt-get', 'install', '-y', 'wget', 'unzip'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
34 |
+
subprocess.run(['wget', 'https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
35 |
+
subprocess.run(['apt-get', 'install', '-y', './google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
36 |
+
subprocess.run(['rm', 'google-chrome-stable_current_amd64.deb'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
37 |
+
subprocess.run(['apt-get', 'clean'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
38 |
+
else:
|
39 |
+
subprocess.run(['powershell', '-command', 'winget', 'install', 'Google.Chrome', '--force'])
|
40 |
print("Chrome installed!")
|