An API that fetches and returns news, including headline and content, from www.inshorts.com
$ git clone https://github.com/Shreya549/InShortsScraper
$ cd InShortsScraper
$ pip3 install -r requirements.txt
$ python3 manage.py runserver
https://scrape-inshorts.herokuapp.com/scrape
GET
Required:
category = [String]
- Code:
HTTP 200 OK
- Content:
{"news": [ {"headline": "headline_data","content": "content_data"} ] }
- Code:
HTTP 404 Not Found
-
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'
With ❤️ by Shreya Chatterjee