The Browser Scanner Service is a web application built using the NestJS framework. It provides an API to scan web pages, extract and normalize their content, and process it using a language model service. The service leverages Puppeteer for browser automation and OpenAI for text processing.
- Web Page Scanning: Automates the process of opening a web page, extracting its HTML content, and normalizing it.
- Content Normalization: Parses HTML content, extracts relevant information, and processes it using a language model.
- Browser Automation: Uses Puppeteer with various plugins for stealth, ad-blocking, and user-agent anonymization.
- Language Model Integration: Integrates with OpenAI's GPT-4 for advanced text processing.
The project is structured as follows:
- Controllers: Handle incoming HTTP requests and route them to the appropriate services.
- Services: Contain the business logic for scanning and processing web pages.
- DTOs (Data Transfer Objects): Define the shape of data being transferred between layers.
- Common: Contains shared utilities and helper functions.
-
Clone the repository:
git clone https://github.com/yourusername/browser-scanner-service.git cd browser-scanner-service -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following variables:OPENAI_API_KEY: Your OpenAI API key.LOG_COLOR: Enables colored console logs. Set totrueorfalse.
-
Start the application:
npm run start
To use the Browser Scanner Service, send a POST request to the /api/v1/browser/scan endpoint with a JSON body containing the URL and optional authentication details.
Example request:
curl --location --request POST 'http://localhost:3000/api/v1/browser/scan' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://example.com",
"username": "user",
"password": "pass",
"proxy": "http://proxy.com"
}'Description: Scans a web page, extracts its content, and processes it using a language model.
url(string): The URL of the web page to scan.username(string): The username for basic authentication (optional).password(string): The password for basic authentication (optional).proxy(string): The proxy server URL (optional).
status(string): The status of the request (success or error).message(string): A message describing the result of the request.
OPENAI_API_KEY: Your OpenAI API key.LOG_COLOR: Enables colored console logs. Set totrueorfalse.
- Fork the repository.
- Create a new branch (git checkout -b feature/your-feature-name).
- Make your changes.
- Commit your changes (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/your-feature-name).
- Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.