I
I
i_vovani2020-05-01 00:29:07
Python
i_vovani, 2020-05-01 00:29:07

How to parse a phone number from Avito without selenium and various drivers?

I wrote a parser in python to pull phone numbers using selenium webdriver, but I need an option to parse numbers without using a driver

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Karbivnichy, 2020-05-01
@i_vovani

1) Schoolchildren don’t go to school anyway, hire them for a couple of bucks, let them click.
2) Another option is to manually reprint the numbers from the pictures.
3) Well, if you are a very cool programmer, dig into js, ​​it’s all business there, send a get request to the address

https://www.avito.ru/items/phone/ad_id
with parameters:
5eab4525a90fd705297405.png
I told you half, it's up to you to find out how pkey and searchHash are generated.
Added:
Here is the code, I copied the parameters from the browser. If you manage to understand how they (or rather, how their values) are generated, then it's in the bag):
Attention! Crutches were found in the code!)
import requests
import base64

params = {	'pkey':'dfed69290bc453b834e2e0e2f16bf630',	# Осталось узнать, как генерируется это значение!
      'vsrc':'r',
      'searchHash':'ttv948zc8v4kg0oc4k0o8wok04w8ook'	# И это тоже!
      }

url = 'https://www.avito.ru/items/phone/1315030387'

response = requests.get(url,params=params)

with open("imageToSave.png", "wb") as fh:
    fh.write(base64.decodebytes(response.text[34:-2].encode()))

At the output, we get a picture with a number for an ad with id 1315030387. It’s not a problem to recognize it in Python.

N
Nadim Zakirov, 2020-05-01
@zkrvndm

On the mobile version, the phone number is issued directly, track where it is downloaded from and knock there with the necessary parameters. Or, download the picture with the number from the PC version, and then there are two options to choose from:
1. Send the picture for recognition to any anti-captcha service
2. Write a lib for recognition, if you know how to work with arrays, nothing complicated
An example of a script for recognizing numbers from picture.

F
Fox Code, 2021-01-20
@foxcode85

Here is a simple solution, everything works without image recognition - link to the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question