Giter Club home page Giter Club logo

web-crawler's Introduction

Page crawler

Project is a crawler for given url setup in src/index.ts file. Project is using node 8.x.x and Typescript and write results into standard output.

Prerequest

  1. Install yarn and node on you local machine

Install yarn and node on you local machine

MacOS

You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed.

brew install yarn

MacPorts

You can install Yarn through MacPorts. This will also install Node.js if it is not already installed.

sudo port install yarn

For other system installation follow instruction on Yarn official page

Getting started

Clone the repo and install Node dependencies

git clone https://github.com/marcelijanowski/web-crawler.git
yarn install

Running project locally

To run project on local machine run command:

yarn start

Project Structure

└── src                         # app source code
    └── index.ts                # app entry module with routing config

Running unit test

Test are written in mocha and chai. To run type in command line :

  • Run yarn jest

Running linting

To test is written code is following standard we use tslint and rules are in tslint.json file To run linter :

  • Run yarn lint

Tradeoffs/ Assumptions

Solution is slow and taking around 50 seconds for https://wiprodigital.com/ but suggestion at bottom . Sometime even not getting though all url as script is block by server and then we catching error and returing process results (not full unfortunatly).

  1. Solution taking into consideration that many supages have same link so we need to keep track of already visited page This is done in line 19 & 20 inside index.ts file
const domainInsternalLinks = new Set(internalLinks(links, hostname));
const difference = differenceBetweenListOfUrls(domainInsternalLinks, allLinks);
  1. For some domain like wipro script will hang for some time as cause page is trying script as spammer and blocking calls giving first 429 and then blocking connection completly. One solution will be doing call in random sequence of time but this will slow script.

  2. Also at moment solution not taking into consideration links that are relative but this might be sorted with adding addional RegExp

  3. This isn't like idea solution which need more work as using recursive function without looking on limitation of webpage open request. Ideal solution would be creating a queing system which will process link in concurent connections and react on 429 error code and retry to get data.

  4. If we talking about cloud solution would be nice to use AWS Lambda or *GCP functions to process link by link and save it into S3 bucket or GCP Storage

  5. Also would be good to Dockerize solution and run e2e on docker - unfortunatly lack of time for now.

web-crawler's People

Contributors

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