GithubHelp home page GithubHelp logo

rattleycooper / htmlscraper Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 202 KB

An API for taking json sitemaps generated by the webscraper.io extension, and emulating webscraper.io's scraping behavior on HTML documents(PHP).

PHP 100.00%

htmlscraper's Introduction

HTMLScraper

An API for taking json sitemaps generated by the webscraper.io extension, and emulating webscraper.io's scraping behavior in PHP.

This is great for creating scraping templates in no time at all..

I have no affiliation with webscraper.io, so please refer to their documentation and their forums for anything you might need in regards to webscraper.io.

Installation : composer require wykleph/html-scraper

Note: Child selectors are not supported yet, but it's on the docket!

To use, require this project with composer, then download the webscraper.io extension for chrome. This is what we will use to generate our sitemap for crawling the html.

Once you have the webscraper.io extension, you will probably want to learn how to use the webscraper.io extension.

Once you have some selectors set up for your sitemap, click on Sitemap (sitemap-name)->Export Sitemap. The json output is what we will use to instantiate a SiteMap object:

$SiteMap = new SiteMap($json);

The next step is to instantiate a HtmlScraper object to consume the SiteMap and the HTML you would like to crawl:

$scraper = new HtmlScraper($SiteMap, $html);
$selections = $scraper->getSelections();

or:

$selections = new HtmlScraper($SiteMap, $html)->getSelections();

The $selections array now contains all of the selections for the sitemap that you used for the given html.

The $selections array should also contain the name of the selector that you set up with webscraper.io as the key, so accessing your selections is as easy as grabbing something like $selections['username-field-name'] or $selections['phone'].

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.