Skip to content

wukimidaire/linkedin_ads_scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn Ad Library Crawler

LinkedIn Ad Crawler Logo

FeaturesInstallationQuick StartDeploymentDocumentation

📋 Overview

A high-performance web crawler that helps businesses and researchers analyze advertising strategies on LinkedIn by automatically collecting and analyzing ads from LinkedIn's Ad Library. Built with FastAPI and Playwright, this tool provides valuable competitive intelligence and market research data.

Tech Stack: Python, FastAPI, Playwright, Docker, CI/CD

Key Features:

  • Automated collection of LinkedIn Ad Library data

  • Asynchronous crawling with parallel processing

🎯 Problem Statement

LinkedIn's Ad Library contains valuable insights about how companies advertise on the platform, but manually collecting this data is time-consuming. This crawler automates the process by:

  • 🤖 Collecting ads from any company's LinkedIn Ad Library
  • 📊 Extracting detailed metrics and creative content
  • 🗃️ Organizing data in a structured JSON format
  • 🔌 Providing an API endpoint for easy integration

✨ Key Features

Data Collection

  • Campaign dates and duration
  • Impression ranges and geographic distribution
  • Demographic targeting (age, gender, seniority)
  • Creative content (images, text, headlines)
  • UTM parameters for campaign tracking
  • Advertiser information

Technical Capabilities

  • ⚡ Asynchronous crawling with Playwright
  • 🔄 Parallel processing for faster data collection
  • 🛡️ Rate limiting and retry mechanisms
  • 📝 Detailed logging system
  • 🐳 Docker containerization
  • ☁️ Cloud-ready deployment

🚀 Getting Started

Prerequisites

  • Python 3.8+
  • Docker (for containerized deployment)
  • Google Cloud SDK (for cloud deployment)

Installation

# Clone the repository
git clone [your-repository-url]
cd linkedin-ad-crawler

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Quick Start

# Run the application
uvicorn app:app --reload

# Access the API
# Swagger UI: http://localhost:8080/docs
# API endpoint: http://localhost:8080/crawl?company_id=[company-id]

🌐 Deployment Options

Docker Deployment

# Build and run container
docker build -t linkedin-crawler .
docker run -p 8080:8080 linkedin-crawler

Google Cloud Run Deployment

# Configure Google Cloud SDK
gcloud init
gcloud auth configure-docker

🔧 Configuration

Environment Variables

  • PORT: Server port (default: 8080)
  • LOG_LEVEL: Logging level (default: INFO)
  • MAX_CONCURRENT_PAGES: Maximum parallel pages (default: 2)
  • RETRY_COUNT: Number of retry attempts (default: 3)

Resource Requirements

  • Memory: Minimum 2GB recommended
  • CPU: 2 cores recommended
  • Storage: Minimal (~500MB)

📊 Example Output

The crawler returns structured JSON data containing ad details:

json { "adId": "123456789", "advertiserName": "Company Name", "startDate": "2024/01/01", "endDate": "2024/01/31", "totalImpressionsRange": "10k-50k", "countryImpressions": [...], "demographics": {...}, "creativeContent": {...} }

🔐 Security & Rate Limiting

  • Built-in rate limiting to prevent API abuse
  • Request filtering for optimal performance
  • Browser isolation in containerized environment
  • Automatic retry mechanism for failed requests

📝 Logging & Monitoring

  • Structured logging with timestamp and severity levels
  • Automatic integration with Google Cloud Logging
  • Performance metrics tracking
  • Error tracking and reporting

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

⚠️ Disclaimer

This tool is for research purposes only. Ensure compliance with LinkedIn's terms of service and rate limiting policies when using this crawler.

📄 MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

🆘 Support

  • Create an issue for bug reports or feature requests
  • Check existing issues before creating new ones
  • Include relevant details and error logs in bug reports

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published