Last active
August 24, 2022 09:56
-
-
Save DxDiagDx/8043c081e7e28c8d3f43200dbb93f57d to your computer and use it in GitHub Desktop.
AVITO - парсинг номера телефона
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
import requests | |
def get_phone(offer_id): | |
"""offer_id - ID объявления""" | |
params = ( | |
('key', 'af0deccbgcgidddjgnvljitntccdduijhdinfgjgfjir'), | |
) | |
url = f'https://m.avito.ru/api/1/items/{offer_id}/phone' | |
response = requests.get(url=url, params=params) | |
result = response.json() | |
if result['status'] == 'ok': | |
phone = urllib.parse.unquote(result['result']['action']['uri'].split('number=')[1]) | |
else: | |
print(result['result']['message']) | |
phone = None | |
return phone | |
def main(): | |
offer_id = '2504159999' | |
phone = get_phone(offer_id) | |
print(phone) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment