Skip to content

Instantly share code, notes, and snippets.

@infinitless
Created January 28, 2022 17:28
Show Gist options
  • Save infinitless/a6cfcbb34d0e682d3fb55e92e41f3589 to your computer and use it in GitHub Desktop.
Save infinitless/a6cfcbb34d0e682d3fb55e92e41f3589 to your computer and use it in GitHub Desktop.
Outputs a list of IMDB top 250 movies
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