Answer the question
In order to leave comments, you need to log in
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 - ЭТО СЛОВО, КОТОРОЕ Я ПЕРЕВЕЛ В ЯНДЕКС ПЕРЕВОДЧИКЕ
Answer the question
In order to leave comments, you need to log in
Yandex has api for these purposes. And yes, do you seriously think that Yandex will allow bots to parse their sites just like that?
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question