I
I
ibr_982017-09-12 14:27:15
Python
ibr_98, 2017-09-12 14:27:15

Why can't I parse the Yandex translator?

Hello!
This code gives me an empty array:

import requests
from bs4 import BeautifulSoup
#ПЕРЕМЕННАЯ С ССЫЛКОЙ НА ЯНДЕКС ПЕРЕВОДЧИК С ПЕРЕВЕДЕННЫМ СЛОВОМ
openUrl = 'https://translate.yandex.ru/?utm_source=wizard&lang=ru-en&text=%D0%BF%D0%BE%D0%BA%D0%B0'

#ОТКРЫВАЕМ ЮРЛ
requestGet = requests.get(openUrl)

#ПОЛУЧАЕМ СОДЕРЖИМОЕ СТРАНИЦЫ
soup = BeautifulSoup(requestGet.content, 'html.parser')

#БЕРЕМ ИЗ СТРАНИЦЫ ПЕРЕВЕДЕННОЕ СЛОВО
so = soup.find_all('span', class_='translation-chunk')
print(so)

#КЛАСС translation-chunk - ЭТО СЛОВО, КОТОРОЕ Я ПЕРЕВЕЛ В ЯНДЕКС ПЕРЕВОДЧИКЕ

works well with other sites .. What could be the matter?
Thank you

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2017-09-12
@Eugen_p

Yandex has api for these purposes. And yes, do you seriously think that Yandex will allow bots to parse their sites just like that?

S
sim3x, 2017-09-12
@sim3x

Take your curl / wget page and look at it in a text editor
bs sees the same thing as you in the editor
To "parse" you either need to figure out how this page communicates with the server and emulate it.
Or use api

R
Ranc58, 2017-09-12
@Ranc58

Yandex translator API .
This will most likely be the most painless way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question