Answer the question
In order to leave comments, you need to log in
How to get "Balabobs" texts via Python?
I really want to generate balaboba responses via Python.
I found in the browser what request the site is making and with what parameters
But when I try to do it through Python, I get a Response 403
from requests import post
params = {
'query': 'Text',
'filter': '1',
'intro': '11'
}
url = "https://zeapi.yandex.net/lab/api/yalm/text3"
req = post(url=url, params=params)
print(req)
Answer the question
In order to leave comments, you need to log in
If it’s still relevant, then he gave the answer:
Why do requests to “Balabob” return 403? And how to do it right?
In the summer it was necessary to send empty cookies. Now the certificate is checked from where the request came from, and a response is given only in the case of a trusted host (Yandex). Perhaps a variant from cloudYandex will give a ride
Take a closer look at what kind of request in the browser, cookies for example.
The parameter params
is responsible for GET parameters. You need to pass the body as a parameterjson
req = post(url=url, json=params)
print(req.json()['text'])
gotta bush)
import requests
def exoooy(text):
headers = {'Content-Type': 'application/json'}
json = {"query":text,"intro":0,"filter":1}
return requests.post('https://zeapi.yandex.net/lab/api/yalm/text3',
json=json, headers=headers).json()
print(exoooy('Привет HABR'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question