File size: 3,301 Bytes
b458f3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743b34b
b458f3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743b34b
b458f3d
 
743b34b
b458f3d
 
 
95cf766
b458f3d
 
 
 
 
743b34b
b458f3d
 
 
 
 
 
 
743b34b
b458f3d
 
 
 
 
 
 
 
 
 
743b34b
b458f3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743b34b
b458f3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
91
92
93
94
95
96
97
98
99
100
101
102
103
# 🚀 Deployment Guide (Free & Lifetime)

This guide will show you how to deploy your Web Scraper API to **Render.com** for free. Render is an excellent cloud platform that supports Python and Playwright out of the box.

## ✅ Prerequisites

1.  **GitHub Account**: You need a GitHub account to host your code.
2.  **Git Installed**: You must have Git installed on your computer.

---

## Step 1: Push Code to GitHub

First, we need to get your code onto GitHub.

1.  **Log in to GitHub** and create a **New Repository**.
    *   Name it something like `Alt-scraper-api`.
    *   Make it **Public** or **Private** (Private is fine).
    *   **Do not** initialize with a README (we have code locally).

2.  **Open your terminal** in the project folder (`d:\webscreper`) and run these commands one by one:

    ```bash
    # Initialize git
    git init

    # Add all files
    git add .

    # Commit changes
    git commit -m "Initial commit for deployment"

    # Link to your new GitHub repo (Replace YOUR_USERNAME and REPO_NAME)
    git remote add origin https://github.com/YOUR_USERNAME/Alt-scraper-api.git

    # Push code
    git push -u origin main
    ```

---
 
## Step 2: Create a Web Service on Render

1.  Go to [dashboard.render.com](https://dashboard.render.com) and sign up/log in.
2.  Click the **"New +"** button and select **"Web Service"**.
3.  Connect your **GitHub** account.
4.  Find your `Alt-scraper-api` repository and click **"Connect"**.

---

## Step 3: Configure the Service

Fill in the details exactly as follows to ensure it works with Flask and Playwright:

*   **Name**: `Alt-scraper` (or whatever you like)
*   **Region**: Closest to you (e.g., Frankfurt or Oregon)
*   **Branch**: `master`
*   **Root Directory**: (Leave blank)
*   **Runtime**: **Python 3**
*   **Build Command**:
    ```bash
    ./build.sh
    ```
*   **Start Command**:
    ```bash
    uvicorn api:app --host 0.0.0.0 --port $PORT --interface wsgi --workers 4 --timeout-keep-alive 600
    ```
*   **Instance Type**: Select **Free**

### ⚠️ crucial: Environment Variables

Scroll down to "Advanced" or "Environment Variables" and make sure these settings are correct. We already set up the `build.sh` script to handle dependencies, so this part should be automatic.

---

## Step 4: Deploy

1.  Click **"Create Web Service"**.
2.  Render will start building your app. You can watch the logs.
    *   It will install Python dependencies.
    *   It will install Chromium (for Playwright).
3.  Once finished, you will see a green checkmark **"Live"**.
4.  Copy your URL (e.g., `https://Alt-scraper.onrender.com`).

---

## Step 5: Test Your API

Now you can use this URL in Postman instead of `127.0.0.1:5050`.

**New Request:**
*   **Method**: `GET`
*   **URL**: `https://YOUR-APP-NAME.onrender.com/api/seo-report?domain=https://example.com`

---

## ℹ️ Important Notes about "Free" Tier

1.  **Spin Down**: The free instance "sleeps" after 15 minutes of inactivity. The first request after sleeping might take 30-50 seconds to wake it up. This is normal.
2.  **Keep Alive (Optional)**: If you want it to stay awake, you can use a free "Uptime Monitor" (like UptimeRobot) to ping your API every 10 minutes.

You now have a fully functional, free, lifetime deployment of your scraper! 🚀