Skip to content

Commit

Permalink
add date filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
khurley committed Sep 1, 2024
1 parent 6936376 commit 9e45b46
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
attrs==24.2.0
beautifulsoup4==4.12.3
bs4==0.0.2
certifi==2024.8.30
charset-normalizer==3.3.2
git-filter-repo==2.45.0
h11==0.14.0
idna==3.8
lxml==5.3.0
outcome==1.3.0.post0
PySocks==1.7.1
requests==2.32.3
Expand Down
23 changes: 19 additions & 4 deletions runbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
import requests
from datetime import datetime, timedelta
import os

SCRAPE_URL = 'https://www.nyfa.org/jobs/?JobQ=Marketing&location=New+York%2C+NY&salary=60000%2Cinf'
Expand Down Expand Up @@ -37,16 +38,30 @@ def check_jobs(driver):

job_results = []

# Define today's date, yesterday, and the day before
today = datetime.today().strftime('%m/%d/%Y')
yesterday = (datetime.today() - timedelta(days=1)).strftime('%m/%d/%Y')
day_before_yesterday = (datetime.today() - timedelta(days=2)).strftime('%m/%d/%Y')

for job in jobs:
title = job.find('h3').text if job.find('h3') else "No title"
link = job.find('a').get('href', "No link")
company = job.find('b', class_='nyfa-orange-color').text if job.find('b') else "No company"
description = job.find('div', class_='grey').text.strip() if job.find('div', class_='grey') else "No description"
print(job)
job_results.append(f"Title: {title}\nCompany: {company}\nDescription: {description}\nLink: nyfa.org{link}")

description_block = job.find('div', class_='grey').text.strip() if job.find('div', class_='grey') else "No description"

# Split the block into individual components
description_parts = description_block.split('|')
date = description_parts[0].strip() if len(description_parts) > 0 else "No date"
location = description_parts[1].strip() if len(description_parts) > 1 else "No location"
job_type = description_parts[2].strip() if len(description_parts) > 2 else "No job type"

# Only add jobs where the date matches today, yesterday, or the day before
if date in [today, yesterday, day_before_yesterday]:
job_results.append(f"Title: {title}\nCompany: {company}\nDate: {date}\nLocation: {location}\nType: {job_type}\nLink: nyfa.org{link}")

return job_results


# Function to send email using Mailgun
def send_email(subject, body):
return requests.post(
Expand Down

0 comments on commit 9e45b46

Please sign in to comment.