R
R
rollthebones2021-06-25 09:40:10
Python
rollthebones, 2021-06-25 09:40:10

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 60d579af1ec5d409752151.png
60d579c70fb10756791268.png
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)

How can I change the code to receive generated responses?

Answer the question

In order to leave comments, you need to log in

7 answer(s)
A
Andrew, 2021-06-29
@rollthebones

If it’s still relevant, then he gave the answer:
Why do requests to “Balabob” return 403? And how to do it right?

S
slikkness, 2021-06-25
@slikkness

Fixed by installing Python 3.7.3

I
Ichi Nya, 2021-12-09
@Ichi

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

R
rPman, 2021-06-25
@rPman

Take a closer look at what kind of request in the browser, cookies for example.

S
soremix, 2021-06-25
@SoreMix

The parameter paramsis responsible for GET parameters. You need to pass the body as a parameterjson

req = post(url=url, json=params)
print(req.json()['text'])

R
Ramis, 2021-06-25
@ramzis

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'))

M
max00d, 2021-06-25
@max00d

60d61d936979d872950060.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question