Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
614 B
4
Indexable
Never
import requests
from bs4 import BeautifulSoup

url = 'https://www.imdb.com/search/keyword/?keywords=year-2019&ref_=fn_kw_kw_2'
response = requests.get(url)

soup = BeautifulSoup(response.text, 'html.parser')
movies = soup.find_all('div', {'class': 'lister-item-content'})
with open("C:\\Users\\Darko\\Desktop\\C++\\fajl.txt", 'w', encoding='utf-8') as file:

    for movie in movies:
        title = movie.find('h3', {'class': 'lister-item-header'}).a.text
        rating = movie.find('div', {'class': 'inline-block ratings-imdb-rating'}).strong.text
        file.write(title + ', ' + rating + '\n')