From 9c50d145f280732e26ecf83c8d2978c07466dfcd Mon Sep 17 00:00:00 2001 From: Peter Thaleikis Date: Sat, 21 Nov 2020 19:15:35 +0400 Subject: [PATCH] Allow to set HTML content --- src/phpscraper.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/phpscraper.php b/src/phpscraper.php index 84aea02..d719e49 100644 --- a/src/phpscraper.php +++ b/src/phpscraper.php @@ -118,6 +118,20 @@ public function go(string $url) $this->current_page = $this->client->request('GET', $url); } + /** + * Allows to set HTML content to process. + * + * @param string $url + * @param string $content + */ + public function setContent(string $url, string $content) + { + $this->current_page = new \Symfony\Component\DomCrawler\Crawler( + $content, + $url + ); + } + /** * Fetch an asset from a given URL *