Giter Club home page Giter Club logo

crawler-word-count's Introduction

crawler-word-count

Web Crawler API to count how many times a word appear in a given URL

API

This API will take a url and a word and count in the requested URL's HTML the number of matches (case sensitive)

Example: http://127.0.0.1:5000/?url=google.com&word=google&ignorecase=true

?url=[url] is the url to be requested

&word=[word] is the word to be searched and counted

&ignorecase=true pass this argument to match ignoring case

Return JSON:

{
	"http://google.com" : {
		"google" : 83
	}
}

Setup

To run this script, you'll need Python 3.x installed and pip to get the packages

Then you must get the extensions Flask-restful and requests

To get then you can simply open a terminal and type: pip install flask-restful and then pip install requests

Running

To run the program, clone the repository or download crawler.py

Open a terminal and go to the folder that contains crawler.py

Type python crawler.py and it will run the service under http://127.0.0.1:5000/

Then all you need to do is request the service passing the arguments:

  • via Browser : you can do it on your browser, just type this in the address box = http://127.0.0.1:5000/?url=google.com&word=google

  • via cURL : open another terminal and type curl http://127.0.0.1:5000/ -d "url=google.com" -d "word=google" -X GET

Testing

The file crawler_test.py is a test suit that was created to be used with the library pytest

Install pytest by running in your terminal pip install pytest

Then, on the root folder of this project, run the terminal command pytest. It will automatically look for and run tests files (that follow a naming convention)

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.