Exemplo n.º 1
0
<?php

require_once '../src/hicurl.php';
unlink('data/history.tmp');
$hicurl = new Hicurl(['history' => 'data/history.tmp']);
$hicurl->loadSingle('www.google.com', null, null, ['name' => 'Google']);
$hicurl->loadSingle('www.facebook.com', null, null, ['name' => 'Facebook']);
$hicurl->compileHistory('data/history.gz');
include "assets/test.htm";
Exemplo n.º 2
0
<?php

require_once '../src/hicurl.php';
$hicurl = new Hicurl(['history' => 'data/history.tmp']);
$hicurl->loadSingle('www.google.com');
$hicurl->compileHistory('data/history.gz', null, true);
include "assets/test.htm";
Exemplo n.º 3
0
<?php

require_once '../src/hicurl.php';
unlink('data/history.tmp');
$result = Hicurl::loadSingleStatic("http://whatismyip.org", null, ['history' => 'data/history.tmp', 'xpath' => true, 'tor' => true]);
//Hicurl::compileHistoryStatic('data/history.tmp','data/history.gz');
//include "assets/test.htm";
if ($result['error']) {
    echo $result['error'];
} else {
    echo $ip = $result['domXPath']->query('/html/body/div[2]/span/text()')->item(0)->nodeValue;
}
Exemplo n.º 4
0
<?php

require_once '../../src/hicurl.php';
Hicurl::serveHistory('../data/history.gz');
Exemplo n.º 5
0
<?php

require_once '../src/hicurl.php';
unlink('data/history.txt');
$hicurl = new Hicurl(['history' => 'data/history.txt']);
$result = $hicurl->loadSingle('https://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=html&rnd=new', null, ['xpath' => ['expression' => '//*[@id="invisible"]/pre/text()', 'compare' => 'x>75'], 'maxFruitlessRetries' => 20, 'fruitlessPassDelay' => 0]);
$hicurl->compileHistory();
include "assets/test.htm";
Exemplo n.º 6
0
 /**
  * Compiles the history-file. This is to be done when the writing to the history-file is complete.
  * This essentialy puts the file in a closed state, gzipping it while also optionally adding extra data.
  * @param string|SplFileObject $historyInput Either a string which is a path to a file that is to be compiled,
  *		or a SplFileObject pointing to that file. This file will be deleted by this function, leaving you only
  *		with its compiled state.
  * @param string|null $historyOutput A filepath-string to the file to be created. This may be omitted in which case
  *		the output-file will be generated in the same directory as the input-file, with the same name but with
  *		".gz" added at the end.
  * @param mixed $customData Anything that is json-friendly can be passed here. It will be assigned to the root of
  *		the final, compiled json-object with the same name("customData")
  * @param bool $keepInputFile If this is set to true then the uncompiled input-file will not be deleted. An example
  *		of a useful case for this would be if daily history-files are generated, and one would like to view the
  *		history so far of today. For this to work $historyOutput needs to be set.
  * @return bool Returns true for success*/
 public static function compileHistoryStatic($historyInput, $historyOutput = null, $customData = null, $keepInputFile = false)
 {
     //At this point the history should be formatted as:
     //{"pages":[page1{},page2{}+tempData+tempDataSize
     //i.e.
     //{"pages":[{"exchanges":[{"content":"foobar","headers":{"http_code":200}}]}{"numPages":1,"idIndices":[]}29
     //(the outer bracket&brace aren't closed)
     if ($keepInputFile) {
         //can't use tmpfile() or SplTempFileObject because we can't get a path from those
         //to feed to exec in compressHistoryFile() so tempnam() is used instead.
         $tempFile = tempnam(dirname($historyInput), 'hicurlHistory');
         copy($historyInput, $tempFile);
         $historyInput = $tempFile;
     }
     $historyInput = new SplFileObject($historyInput, 'r+');
     Hicurl::seekHistoryFileTempData($historyInput);
     $historyInput->fwrite('],"customData":' . json_encode($customData) . '}');
     $historyInput->ftruncate($historyInput->ftell());
     $historyInputPath = $historyInput->getRealPath();
     $historyInput = null;
     //remove the reference to the file so that gzip can delete it as supposed to
     Hicurl::compressHistoryFile($historyInputPath, $historyOutput);
 }
Exemplo n.º 7
0
<?php

require_once '../src/hicurl.php';
unlink('data/history.tmp');
Hicurl::loadSingleStatic('www.google.com', null, ['history' => 'data/history.tmp']);
Hicurl::compileHistoryStatic('data/history.tmp', 'data/history.gz');
include "assets/test.htm";