From 1794f52d5a628064d0d6a3f2e23be01cc359cd73 Mon Sep 17 00:00:00 2001 From: hedii Date: Sun, 5 Jul 2015 12:07:28 +0200 Subject: [PATCH] fix UTF-8 encoding problems --- ColissimoApi/ColissimoApi.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ColissimoApi/ColissimoApi.php b/ColissimoApi/ColissimoApi.php index 1152ca7..eda00ca 100644 --- a/ColissimoApi/ColissimoApi.php +++ b/ColissimoApi/ColissimoApi.php @@ -80,7 +80,7 @@ private function getPage($id) */ private function storeTable($data) { - $table = '' . $this->get_string_between($data, '
', '
') . ''; + $table = '' . $this->get_string_between($data, '
', '
') . ''; $unique_id = uniqid(); $filePath = 'temp/' . $unique_id . '.html'; $file = file_put_contents('temp/' . $unique_id . '.html', $table); @@ -103,8 +103,9 @@ private function storeTable($data) */ private function parse($url) { + $url = file_get_contents($url); $dom = new DOMDocument(); - $html = $dom->loadHTMLFile($url); + @$html = $dom->loadHTML(mb_convert_encoding($url, 'HTML-ENTITIES', 'UTF-8')); $dom->preserveWhiteSpace = false; $tables = $dom->getElementsByTagName('table'); $rows = $tables->item(0)->getElementsByTagName('tr');