Specify a divar.ir category and get its new posts immediately in your Telegram!
There is 5 configuration variables in src/config.php
file:
chatId
: Results Telegram Chat ID, could be a channel or your personal profile idbotToken
: Telegram Bot API Tokenurl
: Divar API endpoint, see the Divar URL section belowneededSpecs
: If you need only some specs in results, put them in this variable as an array, otherwise just fill this with atrue
Also make sure the last_token
file is writable by the script, please do not edit this file manually.
Then you're able to execute the script using
php get-posts.php
However, I suggest to set a cronjob to fetch new posts frequently until you find the post you want.
0 * * * * php /path/to/DivarWatcher/get-posts.php
The easiest way to find the URL is to use Developer Tools' Network tab. Open the website and after setting your filters, open Developer Tools and find the URL has a format like this:
https://api.divar.ir/v8/web-search/...
This URL contains all the filters such as city, colors, types, etc.
- iPhone 13 Pro Max, Gold, Tehran
https://api.divar.ir/v8/web-search/tehran/mobile-phones/apple/apple-iphone-13-pro-max?goods-business-type=all&base_color=gold
- Peugeot 206, Type 5, Production year >= 1395, Tehran
https://api.divar.ir/v8/web-search/tehran/car/peugeot/206/5?production-year=1395-
- Apartment, Tehran Sharak-e Gharb, Size Between 130 to 170, 3 rooms
https://api.divar.ir/v8/web-search/tehran/buy-apartment/shahrak-gharb?size=130-170&rooms=3