-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
31 lines (26 loc) · 834 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
from scraper import scrape
import argparse
from random import randint
import urllib.request
def connect():
try:
urllib.request.urlopen("https://www.google.com/") # Python 3.x
return True
except:
return False
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Helper methods")
parser.add_argument("--term", type=str, nargs="+")
parser.set_defaults(term=[])
args = parser.parse_args()
# checks if its connected to the internet
print("starting")
isInternetConnected = connect()
if isInternetConnected:
if len(args.term) == 0:
print("starting scraping")
scrape("")
else:
randomGuess = randint(0, len(args.term) - 1)
scrape(args.term[randomGuess])
print("setting wallpaper")