Skip to content

Latest commit

 

History

History
114 lines (67 loc) · 2.88 KB

README.md

File metadata and controls

114 lines (67 loc) · 2.88 KB

InShorts API

GitHub code size in bytes GitHub last commit GitHub stars GitHub forks

An API that fetches and returns news, including headline and content, from www.inshorts.com

DOCS


Instructions to run

$ git clone https://github.com/Shreya549/InShortsScraper
$ cd InShortsScraper
$ pip3 install -r requirements.txt
$ python3 manage.py runserver

Contributors

Shreya Chatterjee

URL

https://scrape-inshorts.herokuapp.com/scrape

Method

GET

URL Params

Required:

category = [String]

Success Response

  • Code: HTTP 200 OK
  • Content: {"news": [ {"headline": "headline_data","content": "content_data"} ] }

Error Response:

  • Code: HTTP 404 Not Found

Sample Call:

  • NodeJs - Request:

    var request = require('request');
      var options = {
        'method': 'GET',
        'url': 'https://scrape-inshorts.herokuapp.com/scrape?category=sports',
        'headers': {
           }
        };
    request(options, function (error, response) { 
      if (error) throw new Error(error);
      console.log(response.body);
    });
    
    
  • Python - Requests:

    import requests
    
    url = "https://scrape-inshorts.herokuapp.com/scrape?category=sports"
    
    payload = {}
    headers= {}
    
    response = requests.request("GET", url, headers=headers, data = payload)
    
    print(response.text.encode('utf8')) 
    
    
  • JavaScript - Fetch:

    var requestOptions = {
      method: 'GET',
      redirect: 'follow'
    };
    
    fetch("https://scrape-inshorts.herokuapp.com/scrape?category=sports", requestOptions)
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));
      
    
  • cURL - cURL

    curl --location --request GET 'https://scrape-inshorts.herokuapp.com/scrape?category=sports'
    
    

License

License

With ❤️ by Shreya Chatterjee