added env file to store the keys

pull/231/head
Yariv Menachem 2024-12-11 11:32:58 +02:00
parent cc782ddfc1
commit 968da48728
1 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,6 @@
import asyncio import asyncio
import csv import os
from dotenv import load_dotenv
from typing import List from typing import List
from pymongo import MongoClient, UpdateOne from pymongo import MongoClient, UpdateOne
@ -7,10 +8,14 @@ from telegram import Bot
from jobspy import scrape_jobs from jobspy import scrape_jobs
from jobspy.jobs import JobPost from jobspy.jobs import JobPost
TELEGRAM_API_TOKEN = # Load the .env file
CHAT_ID = load_dotenv()
TELEGRAM_API_TOKEN = os.getenv("TELEGRAM_API_TOKEN")
CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
MONGO_URI = os.getenv("MONGO_URI")
# Connect to MongoDB server # Connect to MongoDB server
client = MongoClient("mongodb://localhost:27017/") client = MongoClient(MONGO_URI)
# Access a database (it will be created automatically if it doesn't exist) # Access a database (it will be created automatically if it doesn't exist)
db = client["jobs_database"] db = client["jobs_database"]
# Access a collection # Access a collection
@ -83,6 +88,7 @@ async def main():
print(f"Found {len(jobs)} jobs") print(f"Found {len(jobs)} jobs")
new_jobs = insert_jobs(jobs, jobs_collection) new_jobs = insert_jobs(jobs, jobs_collection)
await send_job_to_telegram(jobs[0])
for new_job in new_jobs: for new_job in new_jobs:
await send_job_to_telegram(new_job) await send_job_to_telegram(new_job)