Added image collection

This commit is contained in:
R. Eric Wheeler 2016-12-23 12:05:56 -08:00
parent 5772d9f173
commit f5e9c8781c
4 changed files with 115 additions and 3 deletions

View File

@ -25,7 +25,8 @@
"symfony/css-selector": "^2.8", "symfony/css-selector": "^2.8",
"symfony/process": "^2.8", "symfony/process": "^2.8",
"symfony/dom-crawler": "^2.8", "symfony/dom-crawler": "^2.8",
"symfony/console": "^2.8" "symfony/console": "^2.8",
"doctrine/collections": "^1.3"
}, },
"config": { "config": {
"platform": { "platform": {

70
composer.lock generated
View File

@ -4,9 +4,75 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "f32953690bad3de29ca6b2542acc1b29", "hash": "439da2eb89743fa1d87cf656df00dd7b",
"content-hash": "149eb0993f5007ea0ffa28c7f9762f3b", "content-hash": "83d61f647d294058c67c53ea5fab1dc9",
"packages": [ "packages": [
{
"name": "doctrine/collections",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/collections.git",
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\Collections\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Collections Abstraction library",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"array",
"collections",
"iterator"
],
"time": "2015-04-14 22:21:58"
},
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
"version": "6.2.2", "version": "6.2.2",

View File

@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: sikof
* Date: 12/23/2016
* Time: 11:59 AM
*/
namespace Sikofitt\Tor\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\DomCrawler\Crawler;
class ImageCollection
{
private $html;
private $images;
private $crawler;
public function __construct($html)
{
$this->html = $html;
$this->images = new ArrayCollection();
$this->crawler = new Crawler();
}
public function images()
{
$this->crawler->addHtmlContent($this->html);
$images = $this->crawler->filter('img');
foreach($images as $image) {
$this->images->add(new ArrayCollection($image->attributes));
}
return $this->images;
}
}

View File

@ -78,10 +78,18 @@ class TorClient
]); ]);
return $this; return $this;
} }
/**
* @return $this
*/
public function setTorMiddleWare() { public function setTorMiddleWare() {
$this->middleware = Middleware::tor($this->proxy, $this->torControl); $this->middleware = Middleware::tor($this->proxy, $this->torControl);
return $this; return $this;
} }
/**
*
*/
public function createHandlerStack() public function createHandlerStack()
{ {
$this->handlerStack = new HandlerStack(); $this->handlerStack = new HandlerStack();