import requests
from bs4 import BeautifulSoup
def get_first_result_title(movie_title):
search_term = movie_title + "кинопоиск"
search_term = search_term.replace(" ", "+")
url = f"https://www.google.com/search?q={search_term}"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"
}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
first_result_title = soup.find("div", class_="r").a.text
return first_result_title
movie_title = input("Enter movie title: ")
title = get_first_result_title(movie_title)
print(f"Title of first result: {title}")