I
I
Ilya2018-09-29 19:29:31
API
Ilya, 2018-09-29 19:29:31

How to send a question to the site and get an answer from it?

I want to send a question to the p-bot.ru site and get an answer, but the site does not have api, how can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hanneman, 2018-09-29
@Hanneman

Learn how to use the protocol analyzer.
Request:

POST /api/getAnswer HTTP/1.1
Host: p-bot.ru
Connection: keep-alive
Content-Length: 357
Origin: http://p-bot.ru
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Referer: http://p-bot.ru/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,ru;q=0.8,ka;q=0.7
Cookie: dialog_id=21f7ab81-87e6-424a-acbf-3a2e3d23d12c; dialog_sentiment=0; last_visit=1538224647229::1538239047229

request=Putin&request_1=&answer_1=&request_2=&answer_2=&request_3=&answer_3=&bot_name=%CF%81Bot&user_name=%D0%9D%D0%B5%D0%B7%D0%BD%D0%B0%D0%BA%D0%BE%D0%BC%D0%B5%D1%86&dialog_lang=ru&dialog_id=21f7ab81-87e6-424a-acbf-3a2e3d23d12c&dialog_greeting=false&a=public-api&b=3289192115&c=2797253453&d=880116423&e=0.9968169951949974&t=1538239063390&x=6.06113829002269

Answer:
HTTP/1.1 200 OK
Server: nginx/1.10.3 (Ubuntu)
Date: Sat, 29 Sep 2018 16:37:41 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 642
Connection: keep-alive
Access-Control-Allow-Origin: http://p-bot.ru
X-Frame-Options: SAMEORIGIN

{"status":"OK","time":"67 ms","answer":"He is my BFF.","pattern":{"_id":"5b3d93188966a348383b0864","dialog":"f70a712a-c003-4a1b-8b76-a4d249adc8d3","author":"Sykes The Pufferfish","context":"sorry for my english i don t care if you do not want - do not believe but i m not a bot yes you moron do you speak english speak english ","request":"putin ","__v":0,"score":1,"created":"2018-07-05T03:40:08.832Z","useCount":25,"rating":-1,"dislikes":0,"likes":2,"mood":0,"sentiment":0,"mainbase":false,"question":false,"answer":{"set":{"commands":[],"mood":0,"sentiment":0},"variants":["He is my BFF.\n"]},"bot":"roBot","resultAnswer":"He is my BFF."}}

Visually the same:
Request from the form:
Response:
I.e. POST to /api/getAnswer. Further themselves.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question