PHP Classes

PHP Scraping HTML Tag Elements: Retrieve HTML pages and scrape tag elements

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (28 days ago) RSS 2.0 feedStarStarStar 59%Total: 318 This week: 5All time: 7,208 This week: 170Up
Version License PHP version Categories
scrap-html-elements 1.0.2The PHP License5HTML, PHP 5, Parsers
Collaborate with this project Author

HtmlScrapingRequest - github.com

Description

This package can retrieve HTML pages and scrape tag elements.

There is one class that can send HTTP requests to a given server and retrieve a given HTML page.

Another class can find tag elements with a given selector expression and retrieves the elements and the contained data.

Picture of Truong Van Phu
  Performance   Level  
Name: Truong Van Phu <contact>
Classes: 3 packages by
Country: Viet Nam Viet Nam
Innovation award
Innovation award
Nominee: 1x

Winner: 1x

Details

HtmlScrapingRequest

  • Capture URL of the site your want to scrap.
  • Capture selector, eg : img.thumbnail, ...

How to use 1. Require class: require_once 'class.HttpRequest.php'; 2. Using: $http = new Httprequest(); 3. Using: $http->setServer($_POST['domain']);

`if (isset($_POST['domain'])) { //it is a URL of page that you want to scrap`

	$http->setServer($_POST['domain']);

`}`

`$html = $http->send();`

`if (isset($html->error)) {`

	echo json_encode($html); exit();

`}`

`$result = $html->contents;`

`if (isset($_POST['tag-element'])) { // it is a selector (img.thumbnail)`

	$response = array();

	$checkData = $result->find($_POST['tag-element']);

	if (count($checkData)) {

		foreach ($checkData as $key => $check) {

			array_push($response, $check->outertext());

		}

	}

	echo json_encode($response); exit();  // Get your result -> by JSON or any format response

`}`

Donations

I highly appreciate any of your donations.

paypal

  Demo Scraping HTML TagExternal page  

Open in a separate window

  Files folder image Files  
File Role Description
Files folder imageimg (1 file)
Files folder imagejs (1 file)
Plain text file class.HttpRequest.php Class Class source
Plain text file class.SimpleHtmlDom.php Class Class source
Plain text file index.php Example Example script
Plain text file README.md Doc. Documentation

  Files folder image Files  /  img  
File Role Description
  Image file default.gif Icon Icon image

  Files folder image Files  /  js  
File Role Description
  Plain text file script.js Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:318
This week:5
All time:7,208
This week:170Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:83%StarStarStarStarStar
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1372
 
Vulnerable to many attacks.
5 years ago (Velimir Majstorov)
40%StarStarStar
 
For more information send a message to info at phpclasses dot org.