From 6801ee9a0bcd193a538c960b9386fd5ab4004da8 Mon Sep 17 00:00:00 2001 From: Jannik Kramer Date: Sun, 8 Jul 2018 12:52:09 +0200 Subject: [PATCH 1/3] changed package name to align with fork --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bb7115f4..ed9bd894 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "thesoftwarefanatics/php-html-parser", + "name": "jannik-kramer/php-html-parser", "type": "library", "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", "keywords": ["html", "dom", "parser"], - "homepage": "https://github.com/thesoftwarefanatics/php-html-parser", + "homepage": "https://github.com/jannik-kramer/php-html-parser", "license": "MIT", "authors": [ { @@ -15,6 +15,10 @@ "name": "The Software Fanatics GmbH", "email": "dev@thesoftwarefanatics.com", "homepage": "https://thesoftwarefanatics.com" + }, + { + "name": "Jannik Kramer", + "email": "mail@jannikkramer.de" } ], "require": { From dc647f8922c32c1aae964cad24bb40c67e5a25d7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 8 Jul 2018 12:54:02 +0200 Subject: [PATCH 2/3] ignoring .idea and .DS_Store --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 798afc40..3e53fdd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ composer.lock vendor/ phpunit.xml +.idea +.DS_Store From 56ac888d04bc8ebe542da05b45fdceb63220f8be Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 8 Jul 2018 13:03:20 +0200 Subject: [PATCH 3/3] curl status code can be read from dom object --- src/PHPHtmlParser/Curl.php | 9 +++++++++ src/PHPHtmlParser/Dom.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/PHPHtmlParser/Curl.php b/src/PHPHtmlParser/Curl.php index a6fcb95f..e84b5943 100644 --- a/src/PHPHtmlParser/Curl.php +++ b/src/PHPHtmlParser/Curl.php @@ -11,6 +11,13 @@ class Curl implements CurlInterface { + /** + * The status code of the response. + * + * @var int + */ + public $statusCode; + /** * A simple curl implementation to get the content of the url. * @@ -36,6 +43,8 @@ public function get($url) throw new CurlException('Error retrieving "'.$url.'" ('.$error.')'); } + $this->statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + return $content; } } diff --git a/src/PHPHtmlParser/Dom.php b/src/PHPHtmlParser/Dom.php index b173b712..1c4b5346 100644 --- a/src/PHPHtmlParser/Dom.php +++ b/src/PHPHtmlParser/Dom.php @@ -30,6 +30,13 @@ class Dom */ public $root; + /** + * The status code if loaded via url. + * + * @var int + */ + public $statusCode; + /** * The raw version of the document string. * @@ -160,6 +167,8 @@ public function loadFromUrl($url, $options = [], CurlInterface $curl = null) $curl = new Curl; } $content = $curl->get($url); + + $this->statusCode = $curl->statusCode; return $this->loadStr($content, $options); }