From 89c7bcc4c5e3c2bec44e11c55f0e00e6d207266e Mon Sep 17 00:00:00 2001 From: Boushra Bettir <116927138+boushrabettir@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:15:33 -0700 Subject: [PATCH 1/2] Create Blacklist class. - Created simple class for blacklisted companies - Use BlackList member function in utils and main to determine if the company is NOT a blacklisted company. --- blacklist.py | 11 +++++++++++ main.py | 30 ++++++++++++++++-------------- utility.py | 39 +++++++++++++++++++++------------------ 3 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 blacklist.py diff --git a/blacklist.py b/blacklist.py new file mode 100644 index 0000000..a601800 --- /dev/null +++ b/blacklist.py @@ -0,0 +1,11 @@ +class BlackList: + """A class holding methods to determine if a company is blacklisted""" + + BLACKLISTED_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.BLACKLISTED_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 From 1adfacb93f2aaa7eb19a7c54fea29ad67a71b8a7 Mon Sep 17 00:00:00 2001 From: Boushra Bettir <116927138+boushrabettir@users.noreply.github.com> Date: Wed, 20 Sep 2023 23:38:49 -0700 Subject: [PATCH 2/2] Update blacklist->blocklist. --- blacklist.py => blocklist.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename blacklist.py => blocklist.py (55%) diff --git a/blacklist.py b/blocklist.py similarity index 55% rename from blacklist.py rename to blocklist.py index a601800..51d2eee 100644 --- a/blacklist.py +++ b/blocklist.py @@ -1,11 +1,11 @@ -class BlackList: - """A class holding methods to determine if a company is blacklisted""" +class Blockist: + """A class holding methods to determine if a company is blocklisted""" - BLACKLISTED_COMPANIES = set( + 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.BLACKLISTED_COMPANIES else False + return True if company in self.BLOCKLISTED_COMPANIES else False