-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession20(a).py
More file actions
137 lines (103 loc) · 2.18 KB
/
session20(a).py
File metadata and controls
137 lines (103 loc) · 2.18 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Data Analysis of Indian Movies using HTML Parsing
import requests
import matplotlib.pyplot as plt
from bs4 import BeautifulSoup # External Library for parsing HTML data
url = "https://www.imdb.com/india/top-rated-indian-movies/"
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
"""
tags = soup.find_all("td", class_="titleColumn")
movies = []
for tag in tags:
data = tag.text
movies.append(data.strip())
for movie in movies:
print(movie)
print("*******")
"""
"""
print(movies)
for i in movies:
print(i[17:20])
"""
print("////////////////////////////////////////////////")
tags1 = soup.find_all("td", class_="ratingColumn")
rating = []
for tag in tags1:
data = tag.text
rating.append(data.strip())
"""
for rate in rating:
print(rate)
print("*******")
"""
#print("==================", rating)
x = []
for i in range(0, 20, 2):
y = float(rating[i])
x.append(y)
#print(x)
tags = soup.find_all("span", class_="secondaryInfo")
years = []
for tag in tags:
data = tag.text
years.append(data.strip())
h = []
v = []
for i in range(0, len(years)):
y = years[i]
z = int(y[1:5])
if 2000 <= z <= 2010:
v.append(z)
else:
continue
for i in range(0, 10):
h.append(v[i])
print(h)
print(x)
print("====================")
print(h)
"""
print(years)
for year in years:
print(year)
print("*******")
"""
d = dict()
for i in range(0, 10):
d.update({h[i]: x[i]})
print("-------------------------------")
print(d)
h.sort()
print(h)
finalRating = []
for i in range(0 ,10):
j = h[i]
finalRating.append(d[j])
print(finalRating)
"""
two list->finalRating -> Ratings
h -> sorted years
"""
url1 = "https://www.imdb.com/chart/top-english-movies"
response1 = requests.get(url1)
soup = BeautifulSoup(response1.text, "html.parser")
"""
tags = soup.find_all("td", class_="titleColumn")
movies = []
for tag in tags:
data = tag.text
movies.append(data.strip())
for movie in movies:
print(movie)
print("*******")
"""
"""
print(movies)
for i in movies:
print(i[17:20])
"""
plt.plot(h, finalRating, label="B")
plt.xlabel('Years')
plt.ylabel('Rating')
plt.show()