-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.py
101 lines (95 loc) · 2.36 KB
/
parser.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import sys
import requests
from bs4 import BeautifulSoup
#url from command line arg
URL = "http://" + sys.argv[1]
page = requests.get(URL,headers={"Host": "www.google.com"})
soup = BeautifulSoup(page.content, "html.parser")
#get title
title = soup.title.get_text().lower()
temp = ""
counter = 0
#for each letter in title -> convert to color and add to temp
for el in title:
if (el == 'a'):
temp += "crimson\n"
counter += 1
if (el == 'b'):
temp += "orange\n"
counter += 1
if (el == 'c'):
temp += "olive\n"
counter += 1
if (el == 'd'):
temp += "yellow\n"
counter += 1
if (el == 'e'):
temp += "lawn green\n"
counter += 1
if (el == 'f'):
temp += "medium spring green\n"
counter += 1
if (el == 'g'):
temp += "light green\n"
counter += 1
if (el == 'h'):
temp += "aqua\n"
counter += 1
if (el == 'i'):
temp += "aqua marine\n"
counter += 1
if (el == 'j'):
temp += "dodger blue\n"
counter += 1
if (el == 'k'):
temp += "midnight blue\n"
counter += 1
if (el == 'l'):
temp += "blue violet\n"
counter += 1
if (el == 'm'):
temp += "dark violet\n"
counter += 1
if (el == 'n'):
temp += "violet\n"
counter += 1
if (el == 'o'):
temp += "hot pink\n"
counter += 1
if (el == 'p'):
temp += "bisque\n"
counter += 1
if (el == 'r'):
temp += "saddle brown\n"
counter += 1
if (el == 's'):
temp += "sandy brown\n"
counter += 1
if (el == 't'):
temp += "misty rose\n"
counter += 1
if (el == 'u'):
temp += "mint cream\n"
counter += 1
if (el == 'v'):
temp += "lavender\n"
counter += 1
if (el == 'w'):
temp += "floral white\n"
counter += 1
if (el == 'x'):
temp += "gray\n"
counter += 1
if (el == 'y'):
temp += "gainsboro\n"
counter += 1
if (el == 'z'):
temp += "white smoke\n"
counter += 1
#shape temp
temp = sys.argv[1] + '\n' + str(counter) + '\n' + temp
print(temp)
#write temp to file
text_file = open("temp.txt", "w")
text_file.write(temp)
text_file.close()