mirror of https://github.com/Bunsly/JobSpy
fixed imports
parent
bdb70ff4de
commit
ed27b4233f
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
import json
|
||||
|
||||
from src.jobspy.jobs import JobPost, Location
|
||||
from jobspy.jobs import JobPost, Location
|
||||
from .model import GoozaliColumnTypeOptions, GoozaliResponse, GoozaliRow, GoozaliColumn, GoozaliColumnChoice, GoozaliResponseData
|
||||
from .constants import job_post_column_to_goozali_column, job_post_column_names
|
||||
|
||||
|
|
26
src/main.py
26
src/main.py
|
@ -3,10 +3,10 @@ import os
|
|||
from telegram import Update
|
||||
from telegram.ext import Application, CommandHandler, CallbackQueryHandler
|
||||
|
||||
from src.jobspy import Site
|
||||
from src.jobspy.scrapers.utils import create_logger
|
||||
from src.telegram_handler import TelegramIndeedHandler, TelegramDefaultHandler
|
||||
from src.telegram_handler.button_callback.telegram_callback_handler import TelegramCallHandler
|
||||
from jobspy.scrapers.site import Site
|
||||
from jobspy.scrapers.utils import create_logger
|
||||
from telegram_handler import TelegramIndeedHandler, TelegramDefaultHandler
|
||||
from telegram_handler.button_callback.telegram_callback_handler import TelegramCallHandler
|
||||
|
||||
logger = create_logger("Main")
|
||||
title_filters: list[str] = ["test", "qa", "Lead", "Full-Stack", "Full Stack", "Fullstack", "Frontend", "Front-end",
|
||||
|
@ -18,7 +18,8 @@ if __name__ == "__main__":
|
|||
logger.info("Starting initialize ")
|
||||
_api_token = os.getenv("TELEGRAM_API_TOKEN")
|
||||
search_term = "software engineer"
|
||||
locations = ["Tel Aviv, Israel", "Ramat Gan, Israel", "Central, Israel", "Rehovot ,Israel"]
|
||||
locations = ["Tel Aviv, Israel", "Ramat Gan, Israel",
|
||||
"Central, Israel", "Rehovot ,Israel"]
|
||||
application = Application.builder().token(_api_token).build()
|
||||
tg_callback_handler = TelegramCallHandler()
|
||||
tg_handler_all = TelegramDefaultHandler(sites=[Site.LINKEDIN, Site.GLASSDOOR, Site.INDEED, Site.GOOZALI],
|
||||
|
@ -31,24 +32,29 @@ if __name__ == "__main__":
|
|||
locations=locations,
|
||||
title_filters=title_filters,
|
||||
search_term=search_term)
|
||||
application.add_handler(CommandHandler(Site.GOOZALI.value, tg_handler_goozali.handle))
|
||||
application.add_handler(CommandHandler(
|
||||
Site.GOOZALI.value, tg_handler_goozali.handle))
|
||||
# GlassDoor
|
||||
tg_handler_glassdoor = TelegramDefaultHandler(sites=[Site.GLASSDOOR],
|
||||
locations=locations,
|
||||
title_filters=title_filters,
|
||||
search_term=search_term)
|
||||
application.add_handler(CommandHandler(Site.GLASSDOOR.value, tg_handler_glassdoor.handle))
|
||||
application.add_handler(CommandHandler(
|
||||
Site.GLASSDOOR.value, tg_handler_glassdoor.handle))
|
||||
# LinkeDin
|
||||
tg_handler_linkedin = TelegramDefaultHandler(sites=[Site.LINKEDIN],
|
||||
locations=locations,
|
||||
title_filters=title_filters,
|
||||
search_term=search_term)
|
||||
application.add_handler(CommandHandler(Site.LINKEDIN.value, tg_handler_linkedin.handle))
|
||||
application.add_handler(CommandHandler(
|
||||
Site.LINKEDIN.value, tg_handler_linkedin.handle))
|
||||
# Indeed
|
||||
tg_handler_indeed = TelegramIndeedHandler(locations=locations,
|
||||
title_filters=title_filters,
|
||||
search_term=search_term)
|
||||
application.add_handler(CommandHandler(Site.INDEED.value, tg_handler_indeed.handle))
|
||||
application.add_handler(CallbackQueryHandler(tg_callback_handler.button_callback))
|
||||
application.add_handler(CommandHandler(
|
||||
Site.INDEED.value, tg_handler_indeed.handle))
|
||||
application.add_handler(CallbackQueryHandler(
|
||||
tg_callback_handler.button_callback))
|
||||
logger.info("Run polling from telegram")
|
||||
application.run_polling(allowed_updates=Update.ALL_TYPES)
|
||||
|
|
|
@ -3,8 +3,8 @@ from dotenv import load_dotenv
|
|||
from telegram import Bot, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
from telegram.constants import ReactionEmoji
|
||||
|
||||
from src.jobspy.jobs import JobPost
|
||||
from src.jobspy.scrapers.utils import create_logger
|
||||
from jobspy.jobs import JobPost
|
||||
from jobspy.scrapers.utils import create_logger
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
@ -21,8 +21,10 @@ class TelegramBot:
|
|||
def get_reply_markup(self):
|
||||
keyboard = [
|
||||
[
|
||||
InlineKeyboardButton(ReactionEmoji.FIRE, callback_data=ReactionEmoji.FIRE.name),
|
||||
InlineKeyboardButton(ReactionEmoji.PILE_OF_POO, callback_data=ReactionEmoji.PILE_OF_POO.name)
|
||||
InlineKeyboardButton(ReactionEmoji.FIRE,
|
||||
callback_data=ReactionEmoji.FIRE.name),
|
||||
InlineKeyboardButton(
|
||||
ReactionEmoji.PILE_OF_POO, callback_data=ReactionEmoji.PILE_OF_POO.name)
|
||||
],
|
||||
]
|
||||
|
||||
|
@ -33,10 +35,10 @@ class TelegramBot:
|
|||
Send JobPost details to Telegram chat.
|
||||
"""
|
||||
message = f"Job ID: {job.id}\n" \
|
||||
f"Job Title: {job.title}\n" \
|
||||
f"Company: {job.company_name}\n" \
|
||||
f"Location: {job.location.display_location()}\n" \
|
||||
f"Link: {job.job_url}\n"
|
||||
f"Job Title: {job.title}\n" \
|
||||
f"Company: {job.company_name}\n" \
|
||||
f"Location: {job.location.display_location()}\n" \
|
||||
f"Link: {job.job_url}\n"
|
||||
reply_markup = self.get_reply_markup()
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
from telegram_bot import TelegramBot
|
||||
from telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
|
||||
|
||||
class ButtonCallBackContext():
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from telegram import MaybeInaccessibleMessage
|
||||
from telegram.constants import ReactionEmoji
|
||||
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
from telegram_bot import TelegramBot
|
||||
from telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
|
||||
|
||||
class FireStrategy(ButtonStrategy):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from telegram import MaybeInaccessibleMessage
|
||||
from telegram.constants import ReactionEmoji
|
||||
|
||||
from src.telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
from telegram_handler.button_callback.button_strategy import ButtonStrategy
|
||||
|
||||
|
||||
class PooStrategy(ButtonStrategy):
|
||||
|
@ -14,4 +14,4 @@ class PooStrategy(ButtonStrategy):
|
|||
self._emoji = ReactionEmoji.PILE_OF_POO
|
||||
|
||||
async def execute(self):
|
||||
pass
|
||||
pass
|
||||
|
|
|
@ -4,11 +4,11 @@ from telegram.ext import (
|
|||
ContextTypes,
|
||||
)
|
||||
|
||||
from src.jobspy import create_logger
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.telegram_handler.button_callback.button_callback_context import ButtonCallBackContext
|
||||
from src.telegram_handler.button_callback.button_fire_strategy import FireStrategy
|
||||
from src.telegram_handler.button_callback.button_poo_strategy import PooStrategy
|
||||
from jobspy import create_logger
|
||||
from telegram_bot import TelegramBot
|
||||
from telegram_handler.button_callback.button_callback_context import ButtonCallBackContext
|
||||
from telegram_handler.button_callback.button_fire_strategy import FireStrategy
|
||||
from telegram_handler.button_callback.button_poo_strategy import PooStrategy
|
||||
|
||||
|
||||
class TelegramCallHandler:
|
||||
|
|
|
@ -3,11 +3,11 @@ from telegram.ext import (
|
|||
ContextTypes,
|
||||
)
|
||||
|
||||
from src.jobspy import Site, scrape_jobs
|
||||
from src.jobspy.db.job_repository import JobRepository
|
||||
from src.jobspy.scrapers.utils import create_logger
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.telegram_handler.telegram_handler import TelegramHandler
|
||||
from jobspy import Site, scrape_jobs
|
||||
from jobspy.db.job_repository import JobRepository
|
||||
from jobspy.scrapers.utils import create_logger
|
||||
from telegram_bot import TelegramBot
|
||||
from telegram_handler.telegram_handler import TelegramHandler
|
||||
|
||||
|
||||
class TelegramDefaultHandler(TelegramHandler):
|
||||
|
@ -19,7 +19,8 @@ class TelegramDefaultHandler(TelegramHandler):
|
|||
self.telegram_bot = TelegramBot()
|
||||
self.jobRepository = JobRepository()
|
||||
if len(sites) == 1:
|
||||
self.logger = create_logger(f"Telegram{sites[0].name.title()}Handler")
|
||||
self.logger = create_logger(
|
||||
f"Telegram{sites[0].name.title()}Handler")
|
||||
else:
|
||||
self.logger = create_logger("TelegramAllHandler")
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ from telegram.ext import (
|
|||
ContextTypes,
|
||||
)
|
||||
|
||||
from src.jobspy import Site, scrape_jobs
|
||||
from src.jobspy.db.job_repository import JobRepository
|
||||
from src.jobspy.scrapers.utils import create_logger
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.telegram_handler.telegram_handler import TelegramHandler
|
||||
from jobspy import Site, scrape_jobs
|
||||
from jobspy.db.job_repository import JobRepository
|
||||
from jobspy.scrapers.utils import create_logger
|
||||
from telegram_bot import TelegramBot
|
||||
from telegram_handler.telegram_handler import TelegramHandler
|
||||
|
||||
|
||||
class TelegramIndeedHandler(TelegramHandler):
|
||||
|
@ -18,7 +18,8 @@ class TelegramIndeedHandler(TelegramHandler):
|
|||
self.title_filters = title_filters
|
||||
self.telegramBot = TelegramBot()
|
||||
self.jobRepository = JobRepository()
|
||||
self.logger = create_logger(f"Telegram{self.sites_to_scrap[0].name.title()}Handler")
|
||||
self.logger = create_logger(
|
||||
f"Telegram{self.sites_to_scrap[0].name.title()}Handler")
|
||||
|
||||
async def handle(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
self.logger.info("start handling")
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from src.jobspy.jobs import JobPost
|
||||
from src.jobspy.scrapers.goozali.GoozaliMapper import GoozaliMapper
|
||||
from src.jobspy.scrapers.goozali.GoozaliScrapperComponent import GoozaliScrapperComponent
|
||||
from src.jobspy.scrapers.goozali.constants import extract_goozali_column_name, job_post_column_to_goozali_column
|
||||
from src.jobspy.scrapers.goozali.model import GoozaliColumn, GoozaliFieldChoice, GoozaliResponseData
|
||||
from src.jobspy.scrapers.utils import create_dict_by_key_and_value
|
||||
from jobspy.jobs import JobPost
|
||||
from jobspy.scrapers.goozali.GoozaliMapper import GoozaliMapper
|
||||
from jobspy.scrapers.goozali.GoozaliScrapperComponent import GoozaliScrapperComponent
|
||||
from jobspy.scrapers.goozali.constants import extract_goozali_column_name, job_post_column_to_goozali_column
|
||||
from jobspy.scrapers.goozali.model import GoozaliColumn, GoozaliFieldChoice, GoozaliResponseData
|
||||
from jobspy.scrapers.utils import create_dict_by_key_and_value
|
||||
# URL Example
|
||||
# https://airtable.com/v0.3/view/viwagEIbkfz2iMsLU/readSharedViewData?stringifiedObjectParams=%7B%22shouldUseNestedResponseFormat%22%3Atrue%7D&requestId=reqXyRSHWlXyiRgY9&accessPolicy=%7B%22allowedActions%22%3A%5B%7B%22modelClassName%22%3A%22view%22%2C%22modelIdSelector%22%3A%22viwagEIbkfz2iMsLU%22%2C%22action%22%3A%22readSharedViewData%22%7D%2C%7B%22modelClassName%22%3A%22view%22%2C%22modelIdSelector%22%3A%22viwagEIbkfz2iMsLU%22%2C%22action%22%3A%22getMetadataForPrinting%22%7D%2C%7B%22modelClassName%22%3A%22view%22%2C%22modelIdSelector%22%3A%22viwagEIbkfz2iMsLU%22%2C%22action%22%3A%22readSignedAttachmentUrls%22%7D%2C%7B%22modelClassName%22%3A%22row%22%2C%22modelIdSelector%22%3A%22rows%20*%5BdisplayedInView%3DviwagEIbkfz2iMsLU%5D%22%2C%22action%22%3A%22createDocumentPreviewSession%22%7D%5D%2C%22shareId%22%3A%22shr97tl6luEk4Ca9R%22%2C%22applicationId%22%3A%22app5sYJyDgcRbJWYU%22%2C%22generationNumber%22%3A0%2C%22expires%22%3A%222025-01-02T00%3A00%3A00.000Z%22%2C%22signature%22%3A%223aa292ee44d15aa75d9506200329e413653471f89e000fa370ef9fa38393070a%22%7D
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ import asyncio
|
|||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from src.telegram_bot import TelegramBot
|
||||
from src.tests.test_util import createMockJob
|
||||
from telegram_bot import TelegramBot
|
||||
from tests.test_util import createMockJob
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, date
|
||||
from typing import List
|
||||
|
||||
from src.jobspy import JobPost, Location, Country
|
||||
from jobspy import JobPost, Location, Country
|
||||
|
||||
|
||||
# Creating some test job posts
|
||||
|
|
Loading…
Reference in New Issue