Code Monkey home page Code Monkey logo

isentia-data-engineer-role's Introduction

Coding Sample for Isentia Data Engineer Position

How to install

Platform

  • ubuntu 16.04

Prerequisites

  • Python >= 3.4
  • python3-dev(required by Falcon)
  • lxml(required by Scrapy)
  • Pip
  • Virtualenv
git clone https://github.com/Bernardzzz/Isentia-data-engineer-role.git
cd Isentia-data-engineer-role
Python3 -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt

Configuration

  1. Create config.ini at root directory
  2. Put MongoDB connection link and Readability Parser API token in the file

For example,

[mongodb]
host=[your MongoDB connection link, including username and password]

[readability]
app=[your app name]
token=[your parser token]

Crawler

MongoDB is deployed on Compose as required. If you need access, please feel free to contact me.

How to run

cd src/crawler
scrapy crawl guardian

The crawler scrapes news articles from theguardian.com

REST API

How to run

cd src
gunicorn app:app

How to use

Search articles

Search articles which was scraped from theguardian.com by keywords. `` The search behavior would perform the logical conjunction between keywords.


http://ec2-54-206-48-181.ap-southeast-2.compute.amazonaws.com/search

  • Method:

    GET

  • URL Params

    Required:

    keyword=[string]

  • Success Response:

    • Code: 200
      Content:

      {
        "[article-id]": {
          "title": "blah",
          "url": "blah",
          "content": "blah",
          "author": "blah"
        }
      }
  • Error Response:

    • Code 404 Not Found
      Reason Cannot find matching articles by the given keyword(s)

    • Code: 400 Missing Parameter
      Content:

      {
        "title": "Missing parameter",
        "description": "The \"keyword\" parameter is required"
      }
    • Code: 500 Internal Error
      Content:

      {
        "title": "[Error title]",
        "description": "[Error Reason]"
      }
  • Sample Call:

    /search?keyword=Australia&keyword=Olympics

Test

cd [root directory]
python -m unittest tests/test_search.py

isentia-data-engineer-role's People

Contributors

bernardzzz avatar

Watchers

James Cloos avatar  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.