An AI-powered agent that scrapes pharmaceutical and biotech company websites to extract pipeline asset data and exports it to Excel spreadsheets. Work in progress! Not investment/medical advice.
- AI Analysis: Uses Groq API for intelligent data extraction
- Excel Export: Automated Excel file generation
- Web Interface: Easy-to-use browser interface
- CLI Interface: Command-line interface for automation
- Batch Processing: Efficient scraping with rate limiting
- Individual Testing: Test scraping on specific companies
- Company Name
- Brand Name
- Generic Name
- Indication
- Therapeutic Area
- Modality
- Phase
- Next Catalyst Date
npm installCopy .env.example to .env and add your Groq API key:
GROQ_API_KEY=your_actual_groq_api_key_here
PORT=3000
SCRAPE_DELAY_MS=2000
MAX_CONCURRENT_REQUESTS=3
- Go to Groq Console
- Create an account or sign in
- Generate an API key
- Add it to your
.envfile
- Start the Web Server:
npm start-
Access the Interface: Open your browser and go to:
http://localhost:3000 -
Full Database Scrape:
- Click "Start Full Scrape" to scrape all 100+ companies
- The process runs in the background (30-60 minutes)
- Data is automatically exported to Excel when complete
-
Single Company Test:
- Enter a company name in the search box
- Click "Scrape Company" to test the extraction
- Review the extracted pipeline data
-
Export Data:
- Click "Export to Excel" to download the spreadsheet
- File includes all extracted pipeline assets
- Data is formatted with proper headers and filtering
node cli.js setup# Test API connection
node cli.js test
# List all companies
node cli.js list
# Scrape a single company
node cli.js scrape Pfizer
# Scrape all companies
node cli.js scrape-all --output pipeline_data.xlsx
# Check website accessibility
node cli.js check-access# Interactive company selection
node cli.js scrape
# Custom batch processing
node cli.js scrape-all --batch-size 2 --delay 3000 --output data.xlsx
# Test specific number of companies
node cli.js check-access --sample 20setup- Interactive setup for API key and configurationtest- Test Groq API connectionlist- List all companies in databasescrape [company]- Scrape pipeline data for specific companyscrape-all- Scrape all companies for pipeline datacheck-access- Check which company websites are accessible
- express: Web server framework
- axios: HTTP client for web requests
- cheerio: Server-side HTML parsing (jQuery-like)
- exceljs: Excel file generation
- dotenv: Environment variable management
- commander: CLI framework
- chalk: Terminal colors
- ora: Loading spinners
- inquirer: Interactive prompts
- 2-second delay between requests (configurable)
- Maximum 3 concurrent requests (configurable)
- Respectful scraping to avoid overwhelming servers
- Direct API calls to Groq (no SDK dependency)
- Uses Llama 3 70B model for data extraction
- Structured JSON output for consistent data format
- Robust error handling for network issues
- Graceful degradation for failed requests
- Alternative data sources for blocked websites
- Detailed logging for troubleshooting
drug-database-agent/
├── controllers/
│ └── pharmaController.js # Main scraping logic
├── services/
│ └── groqService.js # Groq API integration
├── data/
│ ├── companies.js # Company database
│ └── alternativeSources.js # Backup data sources
├── public/
│ └── index.html # Web interface
├── output/ # Generated Excel files
├── cli.js # Command line interface
├── server.js # Express server
├── package.json # Dependencies
├── .env # Environment variables
├── README.md # This file
└── CLI_README.md # Detailed CLI documentation
GROQ_API_KEY: Your Groq API key (required)PORT: Server port (default: 3000)SCRAPE_DELAY_MS: Delay between requests (default: 2000ms)MAX_CONCURRENT_REQUESTS: Concurrent request limit (default: 3)
Edit data/companies.js to add/remove companies from the scraping list. Companies are organized by category and include direct pipeline page URLs for better data extraction.
GET /: Web interfaceGET /api/companies: List all companiesGET /api/scrape: Start full scrapePOST /api/scrape-company: Scrape specific companyGET /api/export: Download Excel file
-
Missing API Key
- Ensure GROQ_API_KEY is set in .env file
- Verify the key is valid in Groq Console
- Use
node cli.js setupfor interactive configuration
-
Scraping Failures (403 Forbidden)
- Some websites block automated requests
- The agent includes fallback to alternative data sources
- Use
node cli.js check-accessto test accessibility - Increase delay between requests:
--delay 5000
-
JSON Parse Errors
- The agent includes fallback text extraction
- Check console logs for detailed error information
- Most responses are handled gracefully
-
Memory Issues
- Reduce MAX_CONCURRENT_REQUESTS for large scrapes
- Use smaller batch sizes:
--batch-size 1 - Monitor system resources during operation
- Start with
check-accessto identify accessible websites - Use smaller batch sizes for better reliability
- Increase delays if getting rate limited
- Test single companies before running full scrapes
For issues or questions, check the console logs for detailed error messages. The CLI provides verbose output to help troubleshoot problems.
Install globally to use from anywhere:
npm install -g .
drug-database-agent --helpMIT License