U
U
ubirust2022-03-18 21:54:07
Python
ubirust, 2022-03-18 21:54:07

When parsing a phone on Avito, a different phone number is issued via json. Why is that?

When parsing a phone on Avito, a different phone number is issued via json, which differs from that specified in the ad.

In fact, the phone can be obtained, but, as I understand it, Avito specifically replaces it. How it is possible to bypass it? You need to get the phone that is indicated in the ad. It is clear that through selenium it is possible. I want to understand how you can get the correct number through json.

The Python code itself

import requests, json, sys
# Парсер телефона в конкретном объявлении
key = 'af0deccbgcgidddjgnvljitntccdduijhdinfgjgfjir'
s = requests.Session()
params = {'key': key}
url_get_phone = 'https://m.avito.ru/api/1/items/2117597297/phone' # URL запрос телефона, где после items/ идёт id объявления
phone = s.get(url_get_phone, params=params).json() # Сам запрос
if phone['status'] == 'ok': phone_number = requests.utils.unquote(phone['result']['action']['uri'].split('number=')[1]) # Проверка на наличие телефона
else: phone_number = phone['result']['message']
print(phone_number)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TheAndrey7, 2022-03-19
@TheAndrey7

Replaces how.
https://support.avito.ru/articles/1865

N
Nadim Zakirov, 2022-03-19
@zkrvndm

You do NOT need to parse the phone number. Parse just the ads themselves and links to them. You after all these announcements then all the same somewhere lay out? Post it! That's where you put it, make a similar button Show number - when you click on this button, pull out the number from Avito and show it to the visitor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question