-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
90 lines (75 loc) · 2.65 KB
/
run.sh
File metadata and controls
90 lines (75 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# Google Maps Scraper Runner for macOS
# This script starts the PHP frontend and runs the Python scraper
echo "=== Google Maps Scraper Setup ==="
echo ""
# Check if PHP is installed
if ! command -v php &> /dev/null; then
echo "❌ PHP is not installed. Please install PHP first:"
echo " brew install php"
echo " or download from https://www.php.net/downloads.php"
exit 1
fi
# Check if Python is installed
if ! command -v python3 &> /dev/null; then
echo "❌ Python 3 is not installed. Please install Python 3 first:"
echo " brew install python3"
exit 1
fi
# Setup Python virtual environment
echo "🐍 Setting up Python virtual environment..."
if [ ! -d ".venv" ]; then
echo " Creating virtual environment..."
python3 -m venv .venv
fi
# Activate virtual environment
echo " Activating virtual environment..."
source .venv/bin/activate
# Check if required Python packages are installed
echo "📦 Checking Python dependencies..."
python -c "import playwright; import pandas" 2>/dev/null
if [ $? -ne 0 ]; then
echo "❌ Required packages not installed. Installing from requirements.txt..."
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m playwright install chromium
fi
echo ""
echo "🚀 Starting PHP frontend server..."
echo " The web interface will be available at: http://localhost:8000"
echo " Press Ctrl+C to stop the server when done"
echo ""
# Start PHP server in background
php -S localhost:8000 &
# Store the PHP server PID
PHP_PID=$!
# Wait a moment for server to start
sleep 2
echo "✅ PHP server started (PID: $PHP_PID)"
echo ""
echo "🌐 Opening web interface in browser..."
open http://localhost:8000
echo ""
echo "📋 Instructions to run the Python scraper:"
echo " 1. Open a new terminal window"
echo " 2. Navigate to this directory:"
echo " cd $(pwd)"
echo " 3. Activate the virtual environment:"
echo " source .venv/bin/activate"
echo " 4. Run the scraper with a query:"
echo " python scraper.py \"your search query here\""
echo " Example: python scraper.py \"restaurants near colombo\""
echo ""
echo " The scraper will:"
echo " - Open a browser window (Playwright)"
echo " - Search Google Maps for your query"
echo " - Scrape place details and save to JSON"
echo " - Results appear in the web interface automatically"
echo ""
echo "🛑 To stop the PHP server, press Ctrl+C or run: kill $PHP_PID"
echo " To deactivate virtual environment: deactivate"
echo ""
# Wait for user input before exiting
read -p "Press Enter to exit (server will keep running)..."
# Kill the PHP server when user exits
kill $PHP_PID 2>/dev/null