File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 1515 ],
1616 "require" : {
1717 "php" : " >=5.4" ,
18- "paquettg/string-encode" : " 0.1.0"
18+ "paquettg/string-encode" : " 0.1.0" ,
19+ "guzzle/guzzle" : " v3.8.0"
1920 },
2021 "require-dev" : {
2122 "phpunit/phpunit" : " 3.7.*"
Original file line number Diff line number Diff line change 11<?php
2+
23namespace PHPHtmlParser ;
34
5+ use Guzzle \Http \Client ;
46use PHPHtmlParser \Dom \HtmlNode ;
57use PHPHtmlParser \Dom \TextNode ;
68
@@ -118,6 +120,21 @@ public function loadFromFile($file)
118120 return $ this ->load ($ document );
119121 }
120122
123+ /**
124+ * Uses guzzle to load the html from the given url.
125+ *
126+ * @param string $url
127+ * @chainable
128+ */
129+ public function loadFromUrl ($ url )
130+ {
131+ $ client = new Client ($ url );
132+ $ response = $ client ->get ()->send ();
133+ $ content = (string ) $ response ;
134+
135+ return $ this ->load ($ content );
136+ }
137+
121138 /**
122139 * Find elements by css selector on the root node.
123140 *
You can’t perform that action at this time.
0 commit comments