Git Product home page Git Product logo

scraper's Introduction

Web Scraper Tool

A simple web scraping tool that extracts links from a given website up to a specified depth. It now includes functionality to filter the results by file extension.

Requirements

  • Python 3.x
  • Pipenv
  • Docker (optional, for running in a Docker container)

Setting Up the Environment

Before running the scraper, ensure that you have pipenv installed. If you do not have pipenv, you can install it using pip:

pip install pipenv

Once pipenv is installed, navigate to the directory containing the Pipfile and set up the environment:

# Navigate to the scraper directory (modify according to your actual directory)
cd path/to/scraper

# Install dependencies from Pipfile
pipenv install

Usage

To use the tool locally, first activate the pipenv shell, then run the following command:

# Activate the pipenv environment
pipenv shell

# Run the scraper
python scrape.py [url] [-m MAX_DEPTH] [-f FILE_EXTENSION]

Arguments and Options

  • url: The URL of the website you want to scrape. This is a required argument.
  • -m, --max_depth: Optional. Specifies the maximum depth for scraping. Defaults to 1 if not specified.
  • -f, --filter: Optional. Filter results by a specific file extension, e.g., 'mkv'.

Examples

Scrape links from a website with the default depth:

python scrape.py http://example.com

Scrape links from a website up to a depth of 3:

python scrape.py http://example.com -m 3

Scrape links from a website, filtering for a specific file extension (e.g., .mkv files):

python scrape.py http://example.com -m 3 -f mkv

To check the version of the tool, use the --version flag:

python scrape.py --version

Running in a Docker Container

You can also run the web scraper tool in a Docker container. Here's how to do it:

Building the Docker Image

Ensure that you have Docker installed on your machine. Then, navigate to the directory containing your Dockerfile and run the following command to build the Docker image:

docker build -t scraper:1.0 .

Running the Docker Container

Once the image is built, you can run the Docker container with the following command:

docker run scraper:1.0 [url] [-m MAX_DEPTH] [-f FILE_EXTENSION]

Replace [url], [-m MAX_DEPTH], and [-f FILE_EXTENSION] with your desired arguments.

Example:

docker run scraper:1.0 http://example.com -m 3 -f mkv

Author

Al Biheiri ([email protected])

scraper's People

Contributors

abiheiri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.