0

I'm trying to get movie names from imdb list my problem is instead of returning the English name that appear in google chrome inspect element it return the Japanese name.

Note: I tried all BeautifulSoup parsers

Code:

import requests
from bs4 import BeautifulSoup
page=requests.get('https://www.imdb.com/list/ls040141830/')
soup = BeautifulSoup(page.text,'lxml')
name = soup.find('h3','lister-item-header')
print(name)

result:

<h3 class="lister-item-header">
<span class="lister-item-index unbold text-primary">1.</span>
<a href="/title/tt0245429/?ref_=ttls_li_tt">Sen to Chihiro no kamikakushi</a>
<span class="lister-item-year text-muted unbold">(2001)</span>
</h3>

expected result as show in page source: enter image description here

as you can see the name in english but im getting it in japanese any help would be appreciated thanks.

4
  • Maybe, after initial page loading, some java script executes and translates local name to English, and in browser you already see it in English? Commented Oct 11, 2018 at 10:37
  • Are you trying to get imdb pages with an ip address from japan? Commented Oct 11, 2018 at 10:37
  • @kosist yes in broser i see it in english Commented Oct 11, 2018 at 10:45
  • @MrAlihoseiny no my normal ip Commented Oct 11, 2018 at 10:46

1 Answer 1

3

Seems if you visit imdb from a non-browser client, imdb will translate the movie names into the original language. You should be able to fix it by add the Accept-Language header to requests

import requests
from bs4 import BeautifulSoup
headers = {"Accept-Language": "en-US, en;q=0.5"}
page=requests.get('https://www.imdb.com/list/ls040141830/', headers = headers)
soup = BeautifulSoup(page.text,'lxml')
name = soup.find('h3','lister-item-header')
print(name)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.