- A very simple single page PHP web scraper class that utilizes the cURL library to scrape web page content. Scrape web pages using GET or POST methods. Also scrape web page content from asp.net based websites using form POST methods.
- Support for:
- GET Method
- POST Method
- ASP Calls
- Retrieve Page Contents by Markup Tag Names
- Retrieve Values from Form Fields
composer require juyal-ahmed/web-scraper
<?php require 'vendor/autoload.php'; // Create a Scraper instance with only the URL specified $scraper = new \PhpFarmer\WebScraper\Scraper('https://example.com'); $pageHtmlContent = $scraper->getPageContent('https://example.com/page.html'); ?>
<?php require 'vendor/autoload.php'; // Create a Scraper instance with custom cache settings $scraperWithCache = new Scraper('https://example.com', true, './custom_cache/', 600); $pageHtmlContent = $scraper->getPageContent('https://example.com/page.html'); ?>
<?php require 'vendor/autoload.php'; // Create a Scraper instance with only the URL specified $scraper = new \PhpFarmer\WebScraper\Scraper('https://example.com'); $pageHtmlContent = $scraper->curl('https://example.com/page.html', "93.118.xx.141:8800", "6USERR:8PASS1"); ?>
<?php $subHtmlContent = $scraper->getHtmlContentBetweenTags($pageHtmlContent, '', ''); ?>
- Include The Class scraper.php in your Working page header.
- Set some default settings.
- Get the page content by its existing methods.
- Split your content by getHtmlContentBetweenTags methods if single content you are searching for.
- If grid data needed, split the content with a needle Ex: explode()
- Then loop it whole and get the content by getHtmlContentBetweenTags again to make the final array of grid data.
- That's' all
Thanks