Transferring Script Files to Local System or VPS
Transferring Script Files to Local System or VPS
This guide explains the process of transferring a Python script for a Facebook Marketplace Scraper and setting it up on either a local system or a VPS. This scraper helps you collect and manage data from online listings efficiently.
Features of the Facebook Marketplace Scraper
- Data Storage: Uses SQLite for local storage and integration with Google Sheets for cloud-based storage.
- Notifications: Optional Telegram Bot integration for updates.
- Proxy Support: Includes compatibility with services like Smartproxy to manage requests.
Local System Setup Process (Windows)
This section outlines the steps to set up the scraper on your local machine.
Prerequisites
Before proceeding, ensure you have:
- Python 3.6 or higher installed.
- Access to Google Cloud with credentials for Google Sheets API.
- An SQLite-supported system.
- A Telegram bot token (optional).
- Dependencies listed in the
requirements.txt
.
Setup Steps
Step 1: Obtain Script Files
- Download the script files (typically a ZIP archive) and extract them.
- Ensure the following files are present:
fb_parser.py
: The main script.requirements.txt
: Python dependencies.
Step 2: Install Dependencies
Open a terminal, navigate to the script folder, and run:
pip install -r requirements.txt
Step 3: Configure Google Sheets API
- Create a Google Cloud project and enable the Sheets API.
- Download the
credentials.json
file and place it in the script folder.
Step 4: Initialize the Database
Run the following command to create the SQLite database:
python fb_parser.py --initdb
Step 5: Configure Telegram Notifications (Optional)
Edit fb_parser.py
and add your bot_token
and bot_chat_id
.
Step 6: Run the Scraper
Start the scraper with:
python fb_parser.py
Step 7: Automation (Optional)
Use Task Scheduler to automate script execution.
VPS Setup Process
VPS Requirements
- VPS with SSH access and Python 3.6+ installed.
- Linux OS (Ubuntu or CentOS preferred).
- Necessary script files and dependencies.
Setup Steps
Step 1: Log in to VPS
Access your VPS via SSH:
ssh username@hostname
Step 2: Transfer Script Files
Upload files using SCP or SFTP:
scp fb_parser.py requirements.txt username@hostname:/path/to/directory
Step 3: Install Python and Dependencies
Update your system and install Python dependencies:
sudo apt update
sudo apt install python3-pip
pip3 install -r requirements.txt
Step 4: Configure Credentials
Follow the same steps as the local setup to configure Google Sheets and Telegram credentials.
Step 5: Run the Scraper
Navigate to the script directory and execute:
python3 fb_parser.py
Step 6: Automate with Cron
Use cron
to schedule periodic script execution:
crontab -e
# Add the line below to run daily at midnight
0 0 * * * python3 /path/to/fb_parser.py
Conclusion
By following this guide, you can effectively transfer and set up the Facebook Marketplace Scraper on your local system or VPS. This tool simplifies the process of collecting and managing online listing data.