Metadata-Version: 2.1
Name: linkedin-autobot
Version: 0.1.6
Summary: Reusable Python toolkit for LinkedIn lead collection, outreach automation, and lead analytics.
Author: Ayoub Ardem
License: Apache-2.0
Project-URL: Homepage, https://github.com/AyoubArdem/linkedin_autobot
Project-URL: Documentation, https://github.com/AyoubArdem/linkedin_autobot
Keywords: linkedin,automation,lead-generation,playwright,analytics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: analytics
Requires-Dist: langchain>=0.3.0; extra == "analytics"
Requires-Dist: langchain-google-genai>=2.1.0; extra == "analytics"
Provides-Extra: automation
Requires-Dist: playwright>=1.50.0; extra == "automation"
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Provides-Extra: django
Requires-Dist: django>=5.0; extra == "django"
Requires-Dist: djangorestframework>=3.15.0; extra == "django"

# linkedin-autobot

`linkedin-autobot` helps you collect LinkedIn profile data, analyze leads, and automate outreach.

## Install

```bash
pip install linkedin-autobot
```

For local browser automation, install automation dependencies manually:

```bash
pip install "linkedin-autobot[automation]"
python -m playwright install chromium
```

## Choose Your Mode

1. Hosted mode: recommended for production (stable, backend-driven).
2. Local bot mode: runs browser automation on the user machine.

## Environment Variables

Hosted:

- `LINKEDIN_AUTOBOT_BASE_URL`
- `LINKEDIN_AUTOBOT_API_KEY` (optional if your backend does not require it)

Local bot:

- `LINKEDIN_EMAIL`
- `LINKEDIN_PASSWORD`

Analytics (optional):

- `GOOGLE_API_KEY`

## Tutorial: Hosted Client

### 1) Create client with `from_env(...)`

```python
from linkedin_autobot import LinkedInAutobotClient

client = LinkedInAutobotClient.from_env()
```

### 2) Collect profile by name with `collect_profile_by_name(name)`

```python
profile = client.collect_profile_by_name("Satya Nadella")
print(profile.profile_url, profile.full_name, profile.title)
```

Returned data fields:

- `profile.profile_url`
- `profile.full_name`
- `profile.title`
- `profile.location`
- `profile.about`
- `profile.experience`
- `profile.status`
- `profile.metadata`

### 3) Collect profile by URL with `collect_profile_by_url(profile_url)`

```python
profile = client.collect_profile_by_url("https://www.linkedin.com/in/satyanadella/")
print(profile.full_name, profile.location)
```

This method returns the same `LinkedInProfile` fields listed above.

### 4) Analyze profile with `analyze_profile(profile, prompt)`

```python
analysis = client.analyze_profile(
    profile,
    prompt="Score this lead and suggest the best outreach angle."
)
print(analysis.score, analysis.decision_maker_level)
```

### 5) Send outreach with `send_connection_request(profile_url, message=None)`

```python
sent = client.send_connection_request(
    "https://www.linkedin.com/in/satyanadella/",
    message="Hi Satya, I would love to connect."
)
print(sent)
```

## Tutorial: Local Bot

### 1) Install local requirements, then create bot with `from_env(...)` and login with `login()`

```python
from linkedin_autobot import LinkedInBot

with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
```

### 2) Open a profile with `visit_profile(profile_url)`

```python
with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
    bot.visit_profile("https://www.linkedin.com/in/satyanadella/")
```

### 3) Find profile URL with `find_profile_url_by_name(name)`

```python
with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
    profile_url = bot.find_profile_url_by_name("Satya Nadella")
    print(profile_url)
```

### 4) Collect profile with `collect_profile(profile_url)`

```python
with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
    profile = bot.collect_profile("https://www.linkedin.com/in/satyanadella/")
    print(profile.full_name, profile.title)
```

Returned data fields:

- `profile.profile_url`
- `profile.full_name`
- `profile.title`
- `profile.location`
- `profile.about`
- `profile.experience`
- `profile.status`
- `profile.metadata`

### 5) Collect by name with `collect_profile_by_name(name)`

```python
with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
    profile = bot.collect_profile_by_name("Satya Nadella")
    print(profile.profile_url)
```

This method returns the same `LinkedInProfile` fields listed above.

### 6) Send request with `send_connection_request(profile_url, message=None)`

```python
with LinkedInBot.from_env(headless=False) as bot:
    bot.login()
    sent = bot.send_connection_request(
        "https://www.linkedin.com/in/satyanadella/",
        message="Hi Satya, let's connect."
    )
    print(sent)
```

### 7) Close bot manually with `close()`

```python
from linkedin_autobot import LinkedInBot

bot = LinkedInBot.from_env(headless=False)
bot.login()
# ... your actions ...
bot.close()
```

## Tutorial: Local Analytics Engine

### Analyze with `LeadAnalyticsEngine.analyze(profile, prompt)`

```python
from linkedin_autobot import LeadAnalyticsEngine, LinkedInProfile

profile = LinkedInProfile(
    profile_url="https://www.linkedin.com/in/example/",
    full_name="Jane Founder",
    title="Founder & CEO",
    about="B2B growth and sales.",
)

engine = LeadAnalyticsEngine()  # uses GOOGLE_API_KEY if available
result = engine.analyze(profile, "Score this lead and propose outreach.")
print(result.score, result.insights_strategic)
```

## Tutorial: Django Helpers

### `profile_from_lead_model(lead)`

```python
from linkedin_autobot.django import profile_from_lead_model

profile = profile_from_lead_model(lead_instance)
```

### `analyze_lead_model(lead, prompt, api_key=None)`

```python
from linkedin_autobot.django import analyze_lead_model

analysis = analyze_lead_model(lead_instance, "Score this lead.")
print(analysis.score)
```

## Data Models

- `LinkedInCredentials(email, password)`
- `LinkedInProfile(...)`
- `AnalysisResult(...)`

## Exceptions

- `LinkedinAutobotError`
- `MissingDependencyError`
- `AuthenticationError`
- `ScrapingError`

## Practical Notes

- `LinkedInBot.login()` performs preflight checks and raises clear instructions when Chromium is missing.
- If local browser automation is blocked by OS permissions, use hosted mode.
- For production-grade stability, hosted mode is recommended.
