I
I
icenoon2020-05-17 06:15:32
Python
icenoon, 2020-05-17 06:15:32

How to simulate a click or unlock hidden data?

There is an avito page. There are two buttons on each page, one "Write a message" - which creates a dialogue with

the owner
of this ad, the other "Show phone". Show the full owner number
What I tried to do for the task - 1

Each ad has a number, which is obvious
https://www.avito.ru/ufa/nastolnye_kompyutery/4_ya... 1412710700

Each dialog also has a code that includes in yourself your code and the ad code you are applying for
https://www.avito.ru/profile/messenger/channel/u2i- 1412710700-87061295

But there is one BOLD BUT - if I take my code and the code of any ad and substitute them in the dialog URL, then the page will not exist for those ads for which I did not click the "Write a message" button.
I also tried to study the page code to get the link of the "Write a message" button - it doesn't exist.

The second task is completely similar to the first one

. From here, the question is, how can I press any of these buttons with a PYTHON script.
I would be very grateful both for a direct answer in the form of a code, and for any links to articles on modules that can solve my problem both in Russian and in English

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Kuts, 2020-05-17
@icenoon

selenium

...
driver.get('https://www.avito.ru/rostov-na-donu/zapchasti_i_aksessuary/akpp_infiniti_vq37vhr_g37_1791599363')

el = driver.find_element_by_xpath("//button[contains(@data-marker, 'item-phone-button/card')]")
el.click()

el = driver.find_element_by_xpath("//img[contains(@data-marker, 'phone-popup/phone-image')]")

image = Image.open(io.BytesIO(base64.b64decode(el.get_attribute('src').split(',')[1])))
imshow(image)

5ec0df0c2292d211837226.png

A
Arseny, 2020-05-17
Matytsyn @ArsenyMatytsyn

Heavy everyday life of a copier ...
1. Avito's muzzle, like many others, is written in JS and has nothing to do with the backend (It generally doesn't care what kind of YaP), except for requests.
2. DOM is generated dynamically depending on user actions.
3. You will never see all this when poking around in the raw files, since the DOM is already shown in the debugger (F12).
Total:

From here - the question is how do I press any of these buttons with a PYTHON script

The question is not about Python. You need to understand how JS works, how it works in this particular case (look at frameworks like Vue, React, your feet grow from there), and with a light fetch from JavaScript into the back, do whatever you want.

N
Nadim Zakirov, 2020-05-17
@zkrvndm

You will never do this in python, only in JavaScript.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question