A Python script to scrape details from LinkedIn job posts and automatically generate personalized application emails using OpenAI.
- Scrapes LinkedIn post content and metadata
- Extracts author information
- Identifies job postings and extracts job details (title, experience, technologies, remote status)
- Extracts hashtags from posts
- Captures engagement metrics (likes, comments, shares)
- Automatically generates personalized job application emails using OpenAI
- Intelligently selects the best resume (Backend or FullStack) based on job requirements
- Saves data to JSON file
- Handles dynamic content loading with Selenium
- Uses Chromium browser with existing profile to maintain login session
- Python 3.7+
- Chromium browser (or Chrome)
- ChromeDriver (automatically managed if using webdriver-manager)
- OpenAI API key (for email generation)
- Resume files:
Backend Resume.pdf(or .docx) andFullStack Resume.pdf(or .docx)
- Install Python dependencies:
pip install -r requirements.txt- (Optional) Install webdriver-manager for automatic ChromeDriver management:
pip install webdriver-managerIf you install webdriver-manager, you can modify the script to use it automatically.
python3 apply.pyThe script will prompt you for the LinkedIn post URL.
- Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY='your-api-key-here'- Run the script:
python3 apply.py- The script will:
- Scrape the LinkedIn post
- Automatically select the best resume (Backend or FullStack) based on job requirements
- Generate a personalized email using OpenAI
- Save the email to
generated_email.txtandgenerated_email.json
python3 apply.py --headlessOption 1: Close Chromium and use profile (Recommended)
# 1. Close all Chromium windows
# 2. Run the script
python3 apply.pyOption 2: Use remote debugging (keep Chromium open)
# 1. Start Chromium with remote debugging:
chromium --remote-debugging-port=9222
# 2. Run the script:
python3 apply.py --remote-port 9222export OPENAI_API_KEY='sk-...'
python3 apply.py
# Enter URL when promptedThe script will:
- Display scraped data in the console
- Save the data to
linkedin_post_data.json - If it's a job post and OpenAI API key is set:
- Automatically select the best resume (Backend or FullStack)
- Generate a personalized email
- Save email to
generated_email.txtandgenerated_email.json
{
"url": "LinkedIn post URL",
"post_id": "Post ID extracted from URL",
"author": {
"name": "Author name"
},
"content": "Full post content",
"job_details": {
"hiring": true/false,
"job_title": "Job title if detected",
"experience_required": "Years of experience",
"location": "Location if mentioned",
"remote": true/false,
"technologies": ["List of technologies"],
"requirements": []
},
"engagement": {
"likes": "Number of likes",
"comments": "Number of comments",
"shares": "Number of shares"
},
"comments": ["Array of comment texts"],
"hashtags": ["#hashtag1", "#hashtag2"],
"timestamp": "Post timestamp"
}The email generator uses OpenAI GPT-4o-mini to create personalized job application emails:
- Intelligent Resume Selection: Automatically chooses between Backend Resume and FullStack Resume based on job requirements
- Personalized Content: Matches your skills and experience to the job requirements
- Professional Tone: Generates professional, compelling emails that highlight your fit for the role
- Specific Details: References specific technologies, responsibilities, and requirements from the job post
- Ready to Send: Outputs complete email with subject, greeting, body, and closing
- FullStack Resume: Used when job requires frontend technologies (React, Angular, Vue, JavaScript, TypeScript)
- Backend Resume: Used for backend-focused positions (.NET, ASP.NET, C#, SQL Server, APIs)
-
OpenAI API Key: Required for email generation. Get one from https://platform.openai.com/api-keys
- Set as environment variable:
export OPENAI_API_KEY='your-key' - Or enter when prompted by the script
- Set as environment variable:
-
Resume Files: Ensure
Backend Resume.pdf(or .docx) andFullStack Resume.pdf(or .docx) are in the same directory -
Authentication: LinkedIn may require you to sign in manually. The browser window will open, and you may need to sign in to your LinkedIn account.
-
Rate Limiting: Be respectful of LinkedIn's servers. Don't scrape too many posts in quick succession.
-
Terms of Service: Make sure your usage complies with LinkedIn's Terms of Service.
-
ChromeDriver: If you encounter ChromeDriver issues, you can:
- Install it manually and add to PATH
- Use webdriver-manager:
pip install webdriver-manager - Update the script to use webdriver-manager (see example below)
If you get ChromeDriver errors, try:
pip install webdriver-managerThen modify the script to use webdriver-manager:
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# In setup_driver method, replace:
# self.driver = webdriver.Chrome(options=chrome_options)
# with:
service = Service(ChromeDriverManager().install())
self.driver = webdriver.Chrome(service=service, options=chrome_options)- LinkedIn may require authentication - sign in when the browser opens
- Some posts may be private or restricted
- LinkedIn's structure may change, requiring selector updates
- The post may require login to view
- LinkedIn's HTML structure may have changed
- The post may be loading dynamically - the script waits 3 seconds, but you may need to increase wait times
The script can automatically send generated emails via Gmail SMTP.
Important: Gmail requires an App Password (not your regular password) for SMTP access.
- Go to Google Account Security
- Under "How you sign in to Google", click 2-Step Verification
- Follow the prompts to enable it (requires phone number)
- Go directly to: App Passwords
- Or: Google Account > Security > 2-Step Verification > App passwords
- Sign in if prompted
- Select app: Mail
- Select device: Other (Custom name)
- Enter: "LinkedIn Email Sender"
- Click Generate
- Copy the 16-character password (format:
xxxx xxxx xxxx xxxx) - Save it securely - you won't see it again!
- When the script asks for your Gmail App Password, paste the 16-character password
- Spaces are optional (you can include or remove them)
- After email generation, the script will ask: "Would you like to send this email now?"
- Enter
yesory - Enter your Gmail address
- Enter your Gmail App Password (the 16-character one from Step 2)
- The email will be sent automatically!
"Authentication failed" error:
- Make sure you're using an App Password, not your regular Gmail password
- Verify 2-Step Verification is enabled
- Check that you copied the full 16-character password correctly
"SMTP error" or connection issues:
- Check your internet connection
- Verify Gmail SMTP is not blocked by firewall
- Try again - Gmail may have temporary rate limits
This script is provided as-is for educational purposes. Use responsibly and in accordance with LinkedIn's Terms of Service.