L
L
lleballex2020-07-16 15:40:08
Python
lleballex, 2020-07-16 15:40:08

How to parse responses from Mail.ru in Python?

You need to write a script that will search for answers from Mail.ru, select a random one from the first, then go to this question and select a random answer. Sounds easy. But the problem arose at the very beginning. I do it like this:

import requests
from bs4 import BeautifulSoup as BS

url = 'https://otvet.mail.ru/search/'
response = requests.get(f'{url}мой вопрос')
soup = BS(response.text, 'html.parser')

But instead of questions, there are a lot of scripts on the site, so choosing them from soup will not work. How to parse questions in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-16
@lleballex

Press F12, open the network tab and see what XHR requests are there.
Spoiler:
Endpoint:
https://otvet.mail.ru/go-proxy/answer_json
Request example:
https://otvet.mail.ru/go-proxy/answer_json?q=%D0%B...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question