-1

How I can get page with other language not default

My code:

import requests
from bs4 import BeautifulSoup


def scrape(page):
    url = page
    result = requests.get(url, stream=True)
    if result.status_code == 200:
      
        soup = BeautifulSoup(requests.get(url).content, 'html.parser')
        return soup

product=scrape("https://www.tatechnix.de/tatechnix/gx/product_info.php?info=p44232")

print(product)

and now when i open this page i get DE lang how I can get it with EN lang?

They havent other URL or prefix for language. Only changes in button.

Edit:

import re
import requests
from bs4 import BeautifulSoup


def scrape(page):
    headers = {'Accept-Language': 'en-US,en;q=0.8'}
    url = page
    result = requests.get(url, stream=True)
    if result.status_code == 200:
        getPage= requests.get(url, headers=headers)
        soup = BeautifulSoup(getPage.content, 'html.parser')

        title=soup.select('.product-info-title-desktop')[0].text
        return title

product=scrape("https://www.tatechnix.de/tatechnix/gx/product_info.php?info=p44232")

print(product)

Nothing change :/

Small Atom
  • 164
  • 13
  • There are header parameters you can pass with the `get` like [Accept-Language](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language) and [Accept-Charset](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Charset). But no guarantees its going to work. The site may not have options for other language or may use other means such as cookies to select. – tdelaney Jun 16 '20 at 07:11
  • Please check the [post](https://stackoverflow.com/questions/39924069/why-does-python-show-me-text-in-chinese). Is this you answer? – Humayun Ahmad Rajib Jun 16 '20 at 07:25
  • Nothing change or im doing something wrong – Small Atom Jun 16 '20 at 07:50

1 Answers1

1

Try it:

import re
import requests
from bs4 import BeautifulSoup


def scrape(page):
    url = page
    result = requests.get(url, stream=True)
    if result.status_code == 200:
        getPage= requests.get(url)
        soup = BeautifulSoup(getPage.content, 'html.parser')

        title=soup.select('.product-info-title-desktop')[0].text
        return title

product=scrape("https://www.tatechnix.de/tatechnix/gx/product_info.php?info=p44232&language=en")

print(product)
dimay
  • 2,768
  • 1
  • 13
  • 22