This project is an OLX bot designed to scrape specific car ads from the OLX website and send notifications via Telegram. The bot runs every 12 hours using APScheduler.
- Scrapes specific car ads from OLX
- Filters ads based on user data
- Sends notifications via Telegram
- Runs every 12 hours
- Python 3.8+
- A Telegram bot token. You can get one by creating a bot with BotFather.
-
Clone the repository:
git clone https://github.com/yourusername/olx-bot.git cd olx-bot
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root directory of the project and add the following variables:BOT_TOKEN=your-telegram-bot-token CHAT_ID=your-telegram-chat-id API_URL=your-olx-api-url
-
Run the bot:
python notify_ads.py
-
Ensure your repository has a
main
branch. -
Add your secrets to the GitHub repository:
BOT_TOKEN
CHAT_ID
API_URL
-
Create a
.github/workflows/deploy.yml
file with the following content:name: Notify Ads Bot on: schedule: - cron: "0 */12 * * *" jobs: notify_ads: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.9" - name: Install dependencies run: | python -m pip install --upgrade pip pip install requests apscheduler python-telegram-bot - name: Run the script env: BOT_TOKEN: ${{ secrets.BOT_TOKEN }} CHAT_ID: ${{ secrets.CHAT_ID }} API_URL: ${{ secrets.API_URL }} run: | python -u notify_ads.py git config user.name github-actions git config user.email github-actions@github.com git add . git commit -m "crongenerated" || exit 0 git push
- The bot fetches car ads from the specified OLX API URL.
- It filters the ads based on user data (e.g., dealer, business, phone visibility).
- It sends notifications for new ads to the specified Telegram chat.
- It stores notified ad IDs in a pickle file to avoid duplicate notifications.
- The bot runs every 5 minutes using APScheduler.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to contribute to this project and enhance its functionality!
For any issues or questions, please open an issue on the GitHub repository.