Skip to main content

Unofficial api of Divar - by Reverse Engineering

Project description

DivarApi 🇮🇷

Under construction! Not compelitly ready for use yet! Currently experimenting and planning!

English / فارسی - Farsi

Developed by Palas - 2023

Examples - getting newest annon from a city (Buggy Alpha Version)

1. Install the pkg using pip


pip3 install DivarApi

Creating A Client

from DivarApi.core import Client



Bot = Client()

# on this example we want to get the data from mashhad city and buy-apartment category

Bot.get_newest_category('mashhad' , 'buy-apartment')



# it returns a bs4 instance , you can specify if you want to have it as json with jsonify = true argument and more...

Getting Number from Token and id

Every post and annon in Divar.ir contains a Token that you can use to get phone number

e.x -> https://divar.ir/v/title/AZgVLMTF

Token is after the title (end of the url) and in this example its { AZgVLMTF }

you can get the phone number using the get_number method as :

from DivarApi.core import Client



Bot = Client()



# if method doesnt work correctly plz use your own jwt token in header

Bot.get_number(AZgVLMTF)

# if this token exists and has a phone number youll get it 

# but if the number is hidden , itll returns Hidden Number!

Getting Image of a post ( annon )

To use this feature you should pass an ID and Token of a post , also you should specify headers fully

how to get ID of a post?

in every image link related to a post you can find it , also you can use the get_newest_category() and there you can find related field get tagged there before the token , i mean :

https://s101.divarcdn.com/static/pictures/1692404705/AZVD2hGi.jpg

in this example , the id is 1692404705 and the token is AZVD2hGi

so you can get the image through get_post_pic:

from DivarApi.core import Client



Bot = Client(header:dict)

Bot.get_post_pic(1692404705 , 'AZVD2hGi' , path = 'E:\\download\basefolder')



#if your jwt token which should be in cookie inside header was expired you'll get this error:

#the cookie you specified is not correct! or jwt is expired

# or if the link was incorrect you'll get statuscode - Bad request

On Developing state which means its not stable completly.

star the rep on github ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

DivarApi-0.0.3.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

DivarApi-0.0.3-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page