Code Monkey home page Code Monkey logo

web_crawler's Introduction

Web Crawler

This is a software program that downloads HTML content from a starting URL and recursively extracts HTML content from URLs found in the resulting pages.

Usage

in order to run Web Crawler you must create a WebCrawler object. the arguments would be:

  1. url - The starting URL for the process.
  2. maximal_amount - The maximum number of unique URLs to extract from each page.
  3. depth - The depth factor to control how deep the recursion should go.
  4. unique_url - A boolean flag indicating whether URLs should be unique across different depths.

then in your app.py you can implement:

from web_crawler import WebCrawler

# creating the object
myCrawler = WebCrawler(url="https://example.com", depth=1, maximal_amount=10, unique_url=True)

# starting the webCrawler
myCrawler.run()

File Storage

The HTML content for each downloaded page will be stored in a separate file with the naming convention <depth>/<url>.html.
Any characters that are not allowed in file names are replaced with underscores.
For example, if the starting URL is https://www.example.com and the recursion reaches a depth of 2, the HTML content for the page at https://www.example.com/page.html will be stored in the file 2/www_example_com_page_html.html.

Dependencies

Get all the program dependencies by running

pip install -r requirments.txt

Tests

This program was developed using Test-Driven Development (TDD) methodology, with tests being written before the implementation code. The test files included in this repository are:

  • testdata.py: Contains test data for the program.
  • test_advanced.py: Contains advanced level tests for the program, testing edge cases and more complex scenarios.
  • test_core_basis.py: Contains basic level tests for the program, testing its core functionality.

All tests can be run using pytest in the root directory of the program. ``` pytest ```

web_crawler's People

Contributors

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