DEV Community

IntelliTools
IntelliTools

Posted on

Filter HackerNews Job Listings with Python in Seconds

When it comes to hiring in the tech industry, access to high-quality job listings is a competitive advantage. Hacker News (HN) has long been a hub for software engineers and remote hiring, but manually sifting through thousands of job posts to find the right candidates is time-consuming and error-prone. This is where HN Job Filter comes in — a Python tool that automates the process of filtering and exporting Hacker News job listings into clean, usable CSV data.

The core value of this tool is its ability to filter job listings by location, making it ideal for remote hiring. It automates the process of gathering and organizing data from Hacker News, saving developers and recruiters hours of manual work each week. The tool is designed to be run in seconds with minimal setup, and it produces clean CSVs with just three fields: company, title, and location.

Let’s walk through how to use this tool and how it can be integrated into a real workflow.

How to Use HN Job Filter

To get started, you'll need Python 3.7+ and the following libraries installed:

pip install requests beautifulsoup4
Enter fullscreen mode Exit fullscreen mode

Once you have the dependencies, you can run the script. Here's a simplified version of the core logic:

import requests
from bs4 import BeautifulSoup
import csv

def fetch_jobs():
    url = 'https://news.ycombinator.com/jobs'
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    job_listings = soup.select('.storylink')
    return job_listings

def parse_job(job):
    title = job.get_text()
    link = job['href']
    return {'title': title, 'link': link}

def save_to_csv(jobs):
    with open('jobs.csv', 'w', newline='') as file:
        writer = csv.DictWriter(file, fieldnames=['title', 'link'])
        writer.writeheader()
        writer.writerows(jobs)

if __name__ == '__main__':
    jobs = [parse_job(job) for job in fetch_jobs()]
    save_to_csv(jobs)
Enter fullscreen mode Exit fullscreen mode

This script fetches the job listings from Hacker News, extracts the title and link, and saves them to a CSV file. While this is a simplified version, it demonstrates the core functionality of the tool — scraping and filtering data from a real-world source.

Filtering by Location

One of the most valuable features of HN Job Filter is its ability to filter by location. This is particularly useful for remote hiring, where you may want to focus on companies that offer remote work or are based in specific regions. Here's how you might extend the script to filter by location:

def filter_by_location(jobs, location):
    filtered = []
    for job in jobs:
        if location in job['title'].lower():
            filtered.append(job)
    return filtered

if __name__ == '__main__':
    jobs = [parse_job(job) for job in fetch_jobs()]
    filtered_jobs = filter_by_location(jobs, 'remote')
    save_to_csv(filtered_jobs)
Enter fullscreen mode Exit fullscreen mode

This code filters the job listings to only include those that mention the word "remote" in the title, which is a common indicator of remote work. You can modify the filter to include other keywords like "remote-first" or "flexible location" depending on your specific needs.

Why This Tool Matters

HN Job Filter is a real-world example of how automation can streamline the hiring process. It’s not just about scraping data — it’s about filtering that data to meet your specific needs. Whether you're a remote software engineer looking for new opportunities or a recruiter trying to find the best candidates, this tool provides a practical solution that saves time and improves efficiency.

The tool is fully automated, requiring no user input once the dependencies are installed. It’s also lightweight, with minimal code and a clear structure, making it easy to understand and modify.

If you're looking for a way to automate hiring with Hacker News job listings, you can find the full script and documentation at https://intellitools.gumroad.com/l/hn-job-filter.

In conclusion, HN Job Filter is a powerful example of how Python and webscraping can be combined to solve real-world problems in the tech industry. It’s a tool that delivers on its promises — saving hours, filtering by location, and exporting clean data — and it’s built with the needs of remote hiring in mind.

Top comments (0)