Created
January 28, 2022 17:28
-
-
Save infinitless/a6cfcbb34d0e682d3fb55e92e41f3589 to your computer and use it in GitHub Desktop.
Outputs a list of IMDB top 250 movies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import re | |
URL = "https://www.imdb.com/chart/top/" | |
response = requests.get(URL) | |
scraped = response.text | |
mysoup = BeautifulSoup(scraped, "html.parser") | |
movies = mysoup.find_all(name="td", class_="titleColumn") | |
movie_titles = [movie.getText().strip().replace("\n", " ") for movie in movies] | |
for n in range(0, 250): | |
print(f"{re.sub(' +', ' ',movie_titles[n])}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment