Skip to content

Instantly share code, notes, and snippets.

@DxDiagDx
Last active August 24, 2022 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DxDiagDx/8043c081e7e28c8d3f43200dbb93f57d to your computer and use it in GitHub Desktop.
Save DxDiagDx/8043c081e7e28c8d3f43200dbb93f57d to your computer and use it in GitHub Desktop.
AVITO - парсинг номера телефона
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