-
Notifications
You must be signed in to change notification settings - Fork 0
Add LinkedIn scraper/chat CLI, Dockerfile, and docker-compose for RAG Gradio UI #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
siva01c
wants to merge
1
commit into
main
Choose a base branch
from
codex/convert-jupyter-notebook-to-python-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| chromium \ | ||
| chromium-driver \ | ||
| fonts-liberation \ | ||
| libasound2 \ | ||
| libatk-bridge2.0-0 \ | ||
| libatk1.0-0 \ | ||
| libcups2 \ | ||
| libdbus-1-3 \ | ||
| libdrm2 \ | ||
| libgbm1 \ | ||
| libgtk-3-0 \ | ||
| libnss3 \ | ||
| libx11-xcb1 \ | ||
| libxcomposite1 \ | ||
| libxdamage1 \ | ||
| libxfixes3 \ | ||
| libxrandr2 \ | ||
| xdg-utils \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| COPY . . | ||
|
|
||
| CMD ["python", "linkedin_tool.py", "chat", "--host", "0.0.0.0", "--port", "7860"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,93 @@ | ||
| # OSINT Tools | ||
| Before running the project, copy .env.default to .env, then update your LinkedIn and OpenAI credentials and API keys in the .env file. | ||
|
|
||
| ## LinkedIn Posts Analyser | ||
| This is a Jupyter Notebook project. The file linkedin.ipynb is a concept for a LinkedIn user post scraper and GenAI analyzer. | ||
| This tool is useful for OSINT purposes or for managing your digital footprint. It can retrieve LinkedIn posts from several years back and export them to a JSON file. | ||
| This repository now includes a **Python script version** of the original Jupyter notebook (`linkedin.ipynb`). | ||
|
|
||
| ## Chat with GenAI | ||
| For the GenAI features, an OpenAI API key is required. In this part, the JSON file is imported into ChromaDB. Then, using the Gradio chat interface, an OpenAI chatbot is loaded with knowledge about the gathered LinkedIn posts. | ||
| ## 1) Setup environment variables | ||
|
|
||
| Copy `.env.default` to `.env` and fill in your credentials/API key: | ||
|
|
||
| ```bash | ||
| cp .env.default .env | ||
| ``` | ||
|
|
||
| Required variables in `.env`: | ||
|
|
||
| - `LINKEDIN_USER` | ||
| - `LINKEDIN_PASSWORD` | ||
| - `LINKEDIN_TARGET_USERNAME` | ||
| - `LINKEDIN_TARGET_NAME` | ||
| - `OPENAI_API_KEY` | ||
|
|
||
| > Keep `.env` private. It is already ignored by git. | ||
|
|
||
| --- | ||
|
|
||
| ## 2) Run as Python script | ||
|
|
||
| Main script: `linkedin_tool.py` | ||
|
|
||
| ### Scrape LinkedIn posts | ||
|
|
||
| ```bash | ||
| python linkedin_tool.py scrape | ||
| ``` | ||
|
|
||
| If you need a visible browser window (instead of headless): | ||
|
|
||
| ```bash | ||
| python linkedin_tool.py scrape --headed | ||
| ``` | ||
|
|
||
| This generates `posts.json`. | ||
|
|
||
| ### Start RAG chat UI (Gradio) | ||
|
|
||
| ```bash | ||
| python linkedin_tool.py chat --host 0.0.0.0 --port 7860 | ||
| ``` | ||
|
|
||
| ### Run scrape + chat in sequence | ||
|
|
||
| ```bash | ||
| python linkedin_tool.py all | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 3) Run with Docker Compose | ||
|
|
||
| Build and start the services: | ||
|
|
||
| ```bash | ||
| docker compose up --build | ||
| ``` | ||
|
|
||
| Docker Compose now starts: | ||
|
|
||
| - `osint` (Python app) | ||
| - `selenium` (Selenium + Chrome browser infrastructure) | ||
|
|
||
| By default, chat is available at http://localhost:7860 and Selenium Grid at http://localhost:4444. | ||
|
|
||
| ### Run scraping inside container | ||
|
|
||
| ```bash | ||
| docker compose run --rm osint python linkedin_tool.py scrape | ||
| ``` | ||
|
|
||
| The `osint` container is preconfigured to use the Selenium browser service via `SELENIUM_REMOTE_URL=http://selenium:4444/wd/hub`. | ||
|
|
||
| ### Start chat after scraping | ||
|
|
||
| ```bash | ||
| docker compose up | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Notes | ||
|
|
||
| - Cookies are stored under `cookies/`. | ||
| - Embedded vector data is stored under `chromadb/`. | ||
| - Scraped posts are saved to `posts.json`. | ||
| - LinkedIn may trigger checkpoint/verification challenges. If that happens, complete verification and rerun. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| services: | ||
| osint: | ||
| build: . | ||
| container_name: osint-linkedin | ||
| env_file: | ||
| - .env | ||
| environment: | ||
| - SELENIUM_REMOTE_URL=http://selenium:4444/wd/hub | ||
| volumes: | ||
| - ./:/app | ||
| ports: | ||
| - "7860:7860" | ||
| depends_on: | ||
| - selenium | ||
| command: ["python", "linkedin_tool.py", "chat", "--host", "0.0.0.0", "--port", "7860"] | ||
|
|
||
| selenium: | ||
| image: selenium/standalone-chrome:latest | ||
| container_name: osint-selenium | ||
| shm_size: 2gb | ||
| ports: | ||
| - "4444:4444" | ||
| - "7900:7900" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compose service always launches
python linkedin_tool.py chat ..., butrun_chathard-fails whenposts.jsonis missing, sodocker compose up --buildon a fresh checkout exits immediately instead of bringing up a usable stack. This default command requires pre-scraped data that new environments do not have yet, making the advertised startup flow fail unless users run scrape manually first.Useful? React with 👍 / 👎.