2017 © Pedro Peláez
 

library phpwebtools

PHP Curl, DOM, web data parsing tools.

image

grithin/phpwebtools

PHP Curl, DOM, web data parsing tools.

  • Friday, January 20, 2017
  • by grithin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Grithin's PHP Web Tools

Curl

Basic curl class to handle the various curl function and avoid some common pitfalls of php curl (ex: post encoding being larger than browser post encoding)., (*1)

Common Use

use \Grithin\Curl;

$curl = new Curl;

# can set headers either directly using 'options' or through instance attributes
$curl->options['CURLOPT_USERAGENT'] = 'harmless autobot';
$curl->user_agent = 'harmless autobot';

# can provide GET parameters as an array or as a string
$response = $curl->get('http://google.com/?s=bob');
$response = $curl->get('http://google.com/',['s'=>'bob']);


$response = $curl->post('http://google.com/',['s'=>'bob']);
$response = $curl->post('http://google.com/','s=bob');
$response = $curl->post('http://google.com/',json_encode(['bob'=>'s']));

File upload

Uses the old style, but works well enough, (*2)

$response = $curl->post('http://thoughtpush.com/', ['s'=>'bob'], ['file1'=>'@'.__FILE__]);

Response Object

The Curl-send methods return a CurlReponse object with a headers array attribute and a body string attribute., (*3)


use \Grithin\Curl; $curl = new Curl; $response = $curl->get('http://thoughtpush.com'); \Grithin\Debug::out($response->headers); /* [base:index.php:14] 1: [ 'Http-Version' : '1.1' 'Status-Code' : '200' 'Status' : '200 OK' 'Server' : 'nginx/1.4.6 (Ubuntu)' 'Date' : 'Fri, 09 Oct 2015 19:36:01 GMT' ... */ \Grithin\Debug::out($response->body); /* [base:index.php:15] 2: ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> */

Debugging

$curl->options[CURLOPT_VERBOSE] = true;

DomTools

Methods used for better handling of DOM and xpath., (*4)

Read the inline code comments, (*5)

list($dom, $xpath) = DomTools::loadHtml($response->body);

WebData

Various web data methods including ones used to fulfill ASP validations by parsing responses and setting post parameters., (*6)

Read the inline code comments, (*7)

The Versions

20/01 2017

dev-master

9999999-dev http://devtools.grithin.com

PHP Curl, DOM, web data parsing tools.

  Sources   Download

Apache-2.0

The Requires

 

by Adam F Frederick

php tools curl dom xpath asp

09/10 2015

v1.0.0

1.0.0.0 http://devtools.grithin.com

PHP Curl, DOM, web data parsing tools.

  Sources   Download

Apache-2.0

The Requires

 

by Adam F Frederick

php tools curl dom xpath asp