tor-spider/example.php

94 lines
2.3 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Created by PhpStorm.
* User: eric
* Date: 12/23/16
* Time: 4:19 PM
*/
require __DIR__ . '/vendor/autoload.php';
2016-12-24 10:04:18 -08:00
/*
if(false === is_dir(__DIR__ . '/images'))
{
mkdir(__DIR__ . '/images');
}
*/
$client = new \Sikofitt\Tor\TorClient();
2016-12-24 10:04:18 -08:00
$resource = \GuzzleHttp\Psr7\StreamWrapper::getResource(new \GuzzleHttp\Psr7\Stream(fopen('http://4sy6ebszykvcv2n6.onion/', 'rb')));
/*$client->get('http://32b5oz2bbtn6gqj3.onion/index.php/Main_Page');
2016-12-24 07:15:34 -08:00
$images = $client->images();
2016-12-24 10:04:18 -08:00
$iterator = $images->getIterator();
while($iterator->valid()) {
/*
* $iterator->current(); is an array of
* $result['fqd'] fully qualified domain uri - example.onion/path/filename.image
* $result['src'] = the image src element, could be fqd or just /path/filename.image
* $result['raw'] = the raw image data
* $result['base64'] = base64 encoded raw data - file_put_contents(base64_decode(base64), file.image);
* $result['html'] = the html of the page the image was retrieved from.
*/
/* foreach($iterator->current() as $key => $value)
{
file_put_contents(__DIR__ . '/images/' .
pathinfo($value['src'], PATHINFO_FILENAME) . '.' .
pathinfo($value['src'], PATHINFO_EXTENSION),
$value['raw']);
}
$iterator->next();
2016-12-24 07:15:34 -08:00
}
2016-12-24 10:04:18 -08:00
*/
2016-12-24 10:04:18 -08:00
/*$client->get('http://4sy6ebszykvcv2n6.onion/');
$images = $client->images();
$html = $client->getHtml();
dump($html);
*/
//dump($resource);
2016-12-24 07:15:34 -08:00
2016-12-24 10:04:18 -08:00
$j = stream_get_contents($resource);
fclose($resource);
dump($j);
/*
$iterator = $images->getIterator();
while($iterator->valid()) {
foreach($iterator->current() as $key => $value)
{
file_put_contents(__DIR__ . '/images/' .
pathinfo($value['src'], PATHINFO_FILENAME) . '.' .
pathinfo($value['src'], PATHINFO_EXTENSION),
$value['raw']);
}
$iterator->next();
}
$testArray = [
'fqd' => null,
'src' => null,
'alt' => null,
'base64' => null,
'html' => null
];
$image = new \Sikofitt\Element\Image('https://www.google.com/file/robots.txt', $testArray);
dump($image);
//$images = $client->images();
//dump($images);
2016-12-24 07:15:34 -08:00
//$client->get('https://de.indymedia.org/index.shtml');
2016-12-24 10:04:18 -08:00
//foreach($images as $image) {
//$image = new \Doctrine\Common\Collections\ArrayCollection();
2016-12-24 10:04:18 -08:00
// dump($image);
//}
//dump($result);
2016-12-24 07:15:34 -08:00
2016-12-24 10:04:18 -08:00
*/