Git Product home page Git Product logo

scraper's Introduction

Python Web Scraping API

This is a Flask server that provides an endpoint to scrape content from websites.

Features

  • Scrapes text content from the following HTML tags: h1, h2, h3, h4, p, and div.
  • Simple GET request interface to extract text from any webpage.

API Usage

Endpoint

  • /scrap?url=<website>: Scrapes the content of the provided URL.

Example Request

To scrape the content of a website, make a request to the endpoint like this:

curl -X GET "https://scraper-py.vercel.app/scrap?url=https://example.com"

Or simply paste the URL into your browser:

https://scraper-py.vercel.app/scrap?url=https://example.com

Response Format

The API returns a JSON object containing the extracted text from the target page. Example response:

{
  "elements": {
    "h1": ["Heading 1 Text"],
    "h2": ["Subheading 1", "Subheading 2"],
    "h3": ["Another Subheading"],
    "h4": [],
    "p": ["Paragraph text content."],
    "div": ["Div content here."]
  },
  "url": "https://example.com/"
}

Example:

Scraping the content of Cloudilic:

  • Request:

    /scrap?url=https://cloudilic.com/
    
  • Response: Scraping Result

Check it out here


Setup

Step 1: Install dependencies

Make sure you have Python installed, then install the necessary libraries:

pip install -r requirements.txt

Step 2: Run the app

Run the Flask application with:

python api/index.py

Step 3: Access the API

Open your browser and visit:

http://127.0.0.1:5000/

You can then use the /scrap endpoint to scrape websites.


Deployment

This server is deployed on Vercel. You can access it here.

scraper's People

Contributors

yousefwahba avatar

Stargazers

Zainab 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.