Code Monkey home page Code Monkey logo

web-crawler's Introduction

Web Crawler

Basic Web Crawler written in Python

Code Climate

List of files:

  1. web-crawler.py - Main program file containing the crawler, the parser and a method to fetch results from google. This file when executed crawls the web based on a query passed by the user

  2. ranking_function.py - This file is used to calculate the ranking function of a given webpage provided a query. The ranking function depends on how much the webpage is relevant to the given query.

  3. customurllib.py - Overriden urllib library for handling http_401 / Unauthorized access error.

Execution:

To execute the program install all the libraries listed in the requirements.txt file. After complete installation run the file web-crawler.py. The program will then ask the user for a query. Based on that query the crawler will crawl the web and write the results in a file named output.txt

Known Bugs:

  1. The program, for some webpages throws a UnicodeEncodeError where it has trouble parsing some unicode to utf-8 while calculating BM25 score and other places. I am unsure what MIME type is causing this error and I am unable to recreate it.

Output file pattern:

Pattern = "URL | BM25 score | depth | return code | time"

Execution:

  1. When the user runs the file web-crawler.py the program asks the user for a search query for focused crawling.

  2. The program then creates an Instance of the class WebCrawler with this query. The creation of the Instance leads to the calling of the method WebCrawler.fetch_google_results().

  3. The google results are then stored in a priority queue along with their depth and Okapi BM25 score.

  4. The Program then calls the method WebCrawler.crawl(). This method retrieves the url with the highest BM25 score from the Priority Queue and then parses it by calling WebCrawler.parse_page() method alongside adding the URL to visited list.

  5. The parse page method extracts all the links from the given webpage, calculates the BM25 score for the page and inserts the page into the URLs priority queue.

  6. Once all links have been parsed we jump back to step 4.

  7. After the required no. of links have been crawled, the output is written to a file output.txt

web-crawler's People

Contributors

darthfork avatar

Watchers

 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.