Code Monkey home page Code Monkey logo

school-scrapper's Introduction

school-scrapper

A package to scrape Tanzania schools

Usage

Add the package from the composer by running composer require megamindame/school_scraper

If you want to get school data by using this package, not use it in your code, you can uncomment the code section you want in the App.php file,

Using the Package

3 types of data can be accessed from 3 education levels. Education levels 1) Primary 2) Secondary 3)Advanced Secondary

Data that can be accessed

  1. schools - An array of formatted school data
  2. nodes - XPath nodelist of all the html link tags. You can iterate through the list to scrape the results page of a school. Check the Xpath documentation to see how you can use the Xpath node.
  3. data - An array of un-formatted school data

Accessing the data

You can initialize any of the fetchers and pass the year you want to fetch. Images are embedded to show the returned data format.

1) Primary

$fetcher = new PrimaryFetcher(2022);

//Get Primary schools
return $fetcher->getSchools();

image

//Get Data
return $fetcher->getPrimaryData();

image

//Get Nodes
return $fetcher->getNodes();

2) Secondary and Advanced Secondary

$fetcher = new SecondaryFetcher(2022);
//or
$fetcher = new AdvancedSecondaryFetcher(2022);

//Get Primary schools
return $fetcher->getSchools();

image

//Get Data
return $fetcher->getData();

image

//Get Nodes
return $fetcher->getNodes();

People who want to fetch results from the nodes can use the Fetcher->getRootUrl() method to get the Root Url. You can take a look at the code to see how the nodes can be used to fetch their corresponding web pages, in this case, school results pages

As stated above, if you want to use the package as a standalone, then you can just download the code, run composer install then check the 'App.php' file for some directions on how to fetch data. Try to uncomment the sections inside the file, then run php index.php. You can try to run php index.php > filename to save the echoed data into a file.

school-scrapper's People

Contributors

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