Features • Installation • Quick Start • Deployment • Documentation
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
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
- 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
- ⚡ Asynchronous crawling with Playwright
- 🔄 Parallel processing for faster data collection
- 🛡️ Rate limiting and retry mechanisms
- 📝 Detailed logging system
- 🐳 Docker containerization
- ☁️ Cloud-ready deployment
- Python 3.8+
- Docker (for containerized deployment)
- Google Cloud SDK (for cloud deployment)
# 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
# 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]
# Build and run container
docker build -t linkedin-crawler .
docker run -p 8080:8080 linkedin-crawler
# Configure Google Cloud SDK
gcloud init
gcloud auth configure-docker
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)
- Memory: Minimum 2GB recommended
- CPU: 2 cores recommended
- Storage: Minimal (~500MB)
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": {...} }
- Built-in rate limiting to prevent API abuse
- Request filtering for optimal performance
- Browser isolation in containerized environment
- Automatic retry mechanism for failed requests
- Structured logging with timestamp and severity levels
- Automatic integration with Google Cloud Logging
- Performance metrics tracking
- Error tracking and reporting
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This tool is for research purposes only. Ensure compliance with LinkedIn's terms of service and rate limiting policies when using this crawler.
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.
- 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