-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpycodes100_53_movie_list.py
More file actions
35 lines (30 loc) · 940 Bytes
/
pycodes100_53_movie_list.py
File metadata and controls
35 lines (30 loc) · 940 Bytes
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
#https://newdigitals.org/2024/02/24/100-basic-python-codes/#must-watch-movie-list
#Must Watch Movie List
import requests
from bs4 import BeautifulSoup
URL = "https://web.archive.org/web/20200518073855/https://www.empireonline.com/movies/features/best-movies-2/"
response = requests.get(URL)
response_text = response.text
soup = BeautifulSoup(response_text, 'html.parser')
movies = []
titles = soup.find_all(name='h3', class_='title')
for i in titles:
with open('movies.txt', 'a',encoding="utf-8" ) as file:
file.write(i.getText()+"\n")
#Example I/O: the file movies.txt containing the list of 100 must watch movies, viz.
100) Stand By Me
99) Raging Bull
98) Amelie
97) Titanic
96) Good Will Hunting
95) Arrival
94) Lost In Translation
93) The Princess Bride
92) The Terminator
91) The Prestige
90) No Country For Old Men
89) Shaun Of The Dead
88) The Exorcist
87) Predator
86) Indiana Jones And The Last Crusade
etc.