L
L
leo97972020-06-02 15:45:40
Python
leo9797, 2020-06-02 15:45:40

How to change the language of received data from imdb?

I get data about 100 popular movies, but I get them in Ukrainian, although I go to the site and everything is in Russian. How to make it so that I would receive data in Russian.

def collect_data(n, i):
    df_date = pd.DataFrame({
        'movie': n,
        'imdb': i,
    })
    print(df_date)


def load_movie_data(url):
    names = list()
    years = []
    imdb_ratings = []
    r = requests.get(url)
    bs = BeautifulSoup(r.text, "html.parser")
    objects = bs.find_all('tr')
    for movie in objects:
        checkins = movie.find('td', class_ = 'posterColumn')
        if checkins is not None:
            name_td = movie.find('td', class_ = 'titleColumn')
            names.append(name_td.contents[1].text)
            imdb = movie.find('td', class_ = 'imdbRating')
            if len(imdb.contents) == 1:
                imdb_ratings.append("-")
            else:
                imdb_ratings.append(imdb.contents[1].text)
    collect_data(names, imdb_ratings)


if __name__ == '__main__':
    load_movie_data("https://www.imdb.com/chart/moviemeter/?sort=ir,desc&mode=simple&page=1")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sundukov, 2020-06-02
@leo9797

Use the header "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question