Giter VIP home page Giter VIP logo

example-web-crawler's Introduction

Example Web Crawler

This is the example web crawler written in Go, that concurrently outputs a simple site map for the given URL.

  • It will stream and output the URLs extracted from all available pages within one host in the real time.
  • It will not revisit the visited pages.
  • It will run workers concurrently, so the order of streamed URLs is not defined.
  • It will stop and return error if the number of visited pages reaches the limit, specified in the arguments (defaults to 1000).
  • It will log all possible errors from the workers to stderr stream.
  • It was implemented to be production ready and cover as many edge cases as possible, although it still has room for improvement (technically and functionally).
  • It has 100% code coverage with tests.

How to build

To build the program you will require Go compiler (ideally 1.11+) and Dep tool:

$ cd $GOPATH/src/github.com/lokhman/example-web-crawler
$ dep ensure -vendor-only
$ go build .

How to start

To start the program you should pass the base URL as the first argument to the executable:

$ ./example-web-crawler https://example.com/

You may also specify the maximum pages limit with -max-pages flag:

$ ./example-web-crawler -max-pages=100 https://example.com/

How to test

The unit tests can be run with:

$ go test -v ./...

The code coverage report can be generated with:

$ go test -v -coverprofile cover.out ./...
$ go tool cover -html=cover.out -o cover.html
$ open cover.html

License

This code is available under the MIT license. LICENSE file describes this in detail.

example-web-crawler's People

Contributors

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