GithubHelp home page GithubHelp logo

web-crawler's Introduction

web-crawler

Write a web crawler that can be given a URL and show all the URLs that URL links to within the domain. It will then find all the URLs that those URLs link to, and carry on until it has built the graph of the website with the links between pages. Display this graph to the user.

E.g. if www.example.com linked to two pages: www.example.com/foo & www.example.com/bar. And www.example.com/foo linked to www.example.com/bar you might see an output like:

www.example.com links to:
  www.example.com/foo
  www.example.com/bar
www.example.com/foo links to:
  www.example.com/bar

Found 3 links to 2 unique URLs.

anything linked outside of the www.example.com domain wouldn't be visited or included in this output.

The will be a number of design decisions to make which might effect what's included in your graph of links between URLs. Stating how many links you find will help comparison of completeness and performance of different solutions you might try.

Adding a Solution

Submit a PR to add a binary under src/bin/.

Things to Consider

  • speed - how to make it as fast as possible?
  • correctness/completeness
    • does it collect all the links it can?
    • does it handle relative links?
    • what to do when links are broken?
    • do you include links to sub-domains?
    • what to do about fragments & queries?
    • etc...
  • input URL - does this have to be the base URL?
  • output - how to display the results? terminal? serve to HTML to view in browser?
  • progress - how to show the user it is working?

If you want to focus on speed and the design of how to achieve it: some basic, by no means correct or complete, implementations of some of "the other bits" are included in src/lib.rs. You can use these and or improve them.

Testing Performance

The solution should ultimately work on any website, and it's worth testing against a range of websites. It would be interesting to see how the performance is impacted between smaller and bigger sites. Starting with smaller websites that do a decent amount of linking internally is probably best.

To test:

cargo build --release
time cargo run --release --bin <your solution binary> -- <url>

Some <url> suggestions:

https://python-poetry.org
https://serde.rs
https://www.beyondmeat.com

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.