import requests from bs4 import BeautifulSoup import csv # Function to fetch Hacker News job postings def fetch_hn_jobs (): url = ' https://news.ycombinator.com/jobs ' response = requests . get ( url ) soup = BeautifulSoup ( response . text , ' html.parser ' ) jobs = [] # Extract job entries for item in soup . select ( ' .athing ' ): # Select job posts title = item . select_one ( ' .titlelink ' ). text link = item . select_one ( ' .titlelink ' )[ ' href ' ] company = item . select_one ( ' .subtext .company ' ). text . strip () role = item . select_one ( ' .subtext .role ' ). text . strip () location = item . select_one ( ' .subtext .location ' ). text . strip () jobs . append ({ ' company ' : company , ' role ' : role , ' location ' : location , ' link ' : link }) return jobs Enter fullscreen mode Exit fullscreen mode The fetch_hn_jobs function above demonstrates how to programmatically extract job postings from Hacker News.…