Skip to main content

Unofficial api of Divar(Scrapping Divar)

Project description

DivarApi 🇮🇷

English / فارسی - Farsi

Developed by V1Z/Palas - 2024

1. Setup and Instalation

pip3 install divar

Usage

Divar lib support both async and sync programming so youre free to use which one you like

from divar import Client # its async client.
from divar import sync_client # its sync client as its name seggests!

AsyncDivarBot = Client()
SyncDivarBot = sync_client()

Getting Category posts ( Agahi ha )

For that you just to need to call GetCategory method on your client object. Example :

#async version be like :
await AsyncDivarBot.GetCategory('CityName', 'Category-Name' , *args , *kwargs)

#sync version be like :
SyncDivarBot.GetCategory('CityName', 'Category-Name' , *args , *kwargs)

Searching in posts ( New Feature )

Its new feature added to lib for your requests and support <3 as method above i saied you need to call it from the client instance. pass the query and also you can pass city codes to get more accurate posts from your city

Examples:

#async version without cities specified returns posts all over IRAN 
await AsyncDivarBot.Search(query = 'iPhone 13')

#async version but cities specified > code hints : mashhad -> 3 , tehran -> 1 , isfahan -> 4
await AsyncDivarBot.Search(query = 'iPhone 13' , cities = [1,3,4])

#<-------------------------Sync version-------------------------/>
#sync version without cities specified returns posts all over IRAN 
syncDivarBot.Search(query = 'iPhone 13')

#sync version but cities specified > code hints : mashhad -> 3 , tehran -> 1 , isfahan -> 4
syncDivarBot.Search(query = 'iPhone 13' , cities = [1,3,4])

Getting post info

Every post in Divar.ir has a Unique identifier named as Token. you can find them at the end of url bar of a post or in methods below.

with GetPost method you can get info about the post like : -Images -Location -Price -Description and etc.

#<---------------------------Async Version-------------------------/>
await AsyncDivarBot.GetPost('Token')

#<---------------------------sync Version-------------------------/>
SyncDivarBot.GetPost('Token')

Authentication (Login/Sign-Up)

Its new Feature implented abvisouly for your requests.

Authentication is 2 step process , first you need to get otp code to your phone number you can get that with sign method which is not friendly cause can be used for spamming since divar doesnt have anti spam algorithm or preventaion with their message service Second you need to login with that otp code on your phone number which returns a jwt-token to work with special methods (login needed) like GetNumber , you can do the second one with login method which needs your phone number and otp code.

Example:

#<---------------------------Async Version-------------------------/>
await AsyncDivarBot.sign('0987654321') # send otp code (6digits) to the number if returns True else Flase.

#Now you need to login with the otp code (if login successful youre free to use special methods i said above)
await AsyncDivarBot.login('0987654321' , '123456')

#<---------------------------Sync Version-------------------------/>
syncDivarBot.sign('0987654321') # send otp code (6digits) to the number if returns True else Flase.

#Now you need to login with the otp code (if login successful youre free to use special methods i said above)
syncDivarBot.login('0987654321' , '123456')

Getting Number of a post

Its login required method so if you didnt login with above method it will ask for your number and your otp code and itll login you if youre not , pass the Token of post as first arg.

#<---------------------------Async Version-------------------------/>
await AsyncDivarBot.GetNumber('PostToken')

#<---------------------------Sync Version-------------------------/>
syncDuvarBot.GetNumber('PostToken')

New Feature Comming in v2.5:

Divar Chat

Map specifing

and more...

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

divar-2.0.1.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

divar-2.0.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file divar-2.0.1.tar.gz.

File metadata

  • Download URL: divar-2.0.1.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for divar-2.0.1.tar.gz
Algorithm Hash digest
SHA256 af6df427f9b8096f4e401b8a17f946e27aa61cbb8c6ca86b9aa8ee63955d482e
MD5 6a87c1633ccdb088d79f498f31052a45
BLAKE2b-256 29bfc160594459c6e1b82eec46cb4e486fe27daf48b6fabe4abef5fe468c1815

See more details on using hashes here.

File details

Details for the file divar-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: divar-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for divar-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a09e90d428a71bf1845ddcf90ef9dcc52205987fae3ceea3792a1924ed5528c
MD5 f85b619d19e94df9b42ed09d6fd4f79c
BLAKE2b-256 69bb44f73512aae46c44057be2ef3232cf5e81e98a9263862e291096607ed74e

See more details on using hashes here.

Supported by

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