Skip to content

Commit 277950e

Browse files
committedJan 7, 2014
Removed the Guzzle dependancy
1 parent 19e23b5 commit 277950e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
 

‎composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
],
1616
"require": {
1717
"php": ">=5.4",
18-
"paquettg/string-encode": "0.1.0",
19-
"guzzle/guzzle": "v3.8.0"
18+
"paquettg/string-encode": "0.1.0"
2019
},
2120
"require-dev": {
2221
"phpunit/phpunit": "3.7.*"

‎src/PHPHtmlParser/Dom.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace PHPHtmlParser;
44

5-
use Guzzle\Http\Client;
65
use PHPHtmlParser\Dom\HtmlNode;
76
use PHPHtmlParser\Dom\TextNode;
87
use stringEncode\Encode;
@@ -126,14 +125,17 @@ public function loadFromFile($file)
126125
* Uses guzzle to load the html from the given url.
127126
*
128127
* @param string $url
128+
* @param CurlInterface $curl
129129
* @chainable
130-
* @throws \Guzzle\Http\Exception\...
131130
*/
132-
public function loadFromUrl($url)
131+
public function loadFromUrl($url, CurlInterface $curl = null)
133132
{
134-
$client = new Client($url);
135-
$response = $client->get()->send();
136-
$content = (string) $response;
133+
if (is_null($curl))
134+
{
135+
// use the default curl interface
136+
$curl = new Curl;
137+
}
138+
$content = $curl->get($url);
137139

138140
return $this->loadStr($content);
139141
}
@@ -309,6 +311,9 @@ protected function clean($str)
309311
// clean out the \n\r
310312
$str = str_replace(["\r\n", "\r", "\n"], ' ', $str);
311313

314+
// strip the doctype
315+
$str = preg_replace("'<!doctype(.*?)>'is", '', $str);
316+
312317
// strip out comments
313318
$str = preg_replace("'<!--(.*?)-->'is", '', $str);
314319

0 commit comments

Comments
 (0)
Please sign in to comment.