diff --git a/blocklist.py b/blocklist.py new file mode 100644 index 0000000..51d2eee --- /dev/null +++ b/blocklist.py @@ -0,0 +1,11 @@ +class Blockist: + """A class holding methods to determine if a company is blocklisted""" + + BLOCKLISTED_COMPANIES = set( + ["Pattern Learning AI - Career & Tech Recruitment Reimagined!"] + ) + + def is_blacklisted_company(self, company: str) -> bool: + """Determines if the company is blacklisted or not""" + + return True if company in self.BLOCKLISTED_COMPANIES else False diff --git a/main.py b/main.py index 89785e6..878d9cf 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ import opportunity as opps from opportunity import Opportunity, OpportunityType from dotenv import load_dotenv +from blacklist import BlackList load_dotenv() # To obtain keys from the .env file @@ -17,7 +18,7 @@ # ----------------- POSTGRES ----------------- TABLE_NAME = os.getenv("DB_TABLE") -MAX_LIST_LENGTH = 13 +MAX_LIST_LENGTH = 15 def create(): @@ -49,19 +50,20 @@ def request_github_internship24_data() -> List[Opportunity]: elements = cell.find_all("td") company = elements[0].text - title = elements[1].text - location = elements[2].text - link = elements[3] - if "🔒" not in link.text: - opportunity = Opportunity( - company, - title, - location, - link.find("a")["href"], - 0, - OpportunityType.INTERNSHIP.value, - ) - github_list.append(opportunity) + if not BlackList().is_blacklisted_company(company): + title = elements[1].text + location = elements[2].text + link = elements[3] + if "🔒" not in link.text: + opportunity = Opportunity( + company, + title, + location, + link.find("a")["href"], + 0, + OpportunityType.INTERNSHIP.value, + ) + github_list.append(opportunity) return github_list diff --git a/utility.py b/utility.py index e91d4da..05a9ad6 100644 --- a/utility.py +++ b/utility.py @@ -7,7 +7,8 @@ import json import google.generativeai as palm from bs4 import BeautifulSoup -from opportunity import Opportunity, OpportunityType +from opportunity import Opportunity +from blacklist import BlackList # ----------------- FOR CLI LIBRARY COMMAND ----------------- @@ -74,23 +75,25 @@ def blueprint_opportunity_formatter( internship_list = [] for elem in div: company = elem.find(class_=company_elem).text.strip() - title = elem.find(class_=title_elem).text.strip() - location = elem.find(class_=location_elem).text.strip() - link = elem.find(class_=link_elem)["href"].split("?")[0] - processed = 0 - - date_difference = calculate_day_difference(elem) - if len(internship_list) < len_of_jobs: - if date_limit and int(days_needed_command_value) >= date_difference: - opportunity = Opportunity( - company, title, location, link, processed, opp_type - ) - else: - opportunity = Opportunity( - company, title, location, link, processed, opp_type - ) - - internship_list.append(opportunity) + if not BlackList().is_blacklisted_company(company): + title = elem.find(class_=title_elem).text.strip() + location = elem.find(class_=location_elem).text.strip() + link = elem.find(class_=link_elem)["href"].split("?")[0] + processed = 0 + + date_difference = calculate_day_difference(elem) + + if len(internship_list) < len_of_jobs: + if date_limit and int(days_needed_command_value) >= date_difference: + opportunity = Opportunity( + company, title, location, link, processed, opp_type + ) + else: + opportunity = Opportunity( + company, title, location, link, processed, opp_type + ) + + internship_list.append(opportunity) return internship_list