summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2018-09-16 00:43:42 +0200
committerMarvin Borner2018-09-16 00:43:42 +0200
commite6386db06c1aae42f7df0727420c8c529c7f29ab (patch)
treebb4a86a81904f5318cd6df3a33b32d056317bede
parent4a7bb4582d68bc35c5b5e2eff8d7b98633c6d8f0 (diff)
Fixed encoding issue :sparkles:
-rw-r--r--crawler.php6
1 files changed, 3 insertions, 3 deletions
diff --git a/crawler.php b/crawler.php
index dd8aec1..1c1f562 100644
--- a/crawler.php
+++ b/crawler.php
@@ -186,8 +186,8 @@ function saveData($urlInfo)
print "\e[96mFinished previous url - crawling: " . $currentUrl . "\n";
- $title = $urlInfo['title'] ?? '';
- $description = $urlInfo['description'] ?? '';
+ $title = mb_convert_encoding($urlInfo['title'] ?? '', 'Windows-1252', 'UTF-8');
+ $description = mb_convert_encoding($urlInfo['description'] ?? '', 'Windows-1252', 'UTF-8');
$language = $urlInfo['language'] ?? 'en';
$hash = md5($currentUrl);
@@ -212,7 +212,7 @@ function alreadyCrawled($url)
function initDbConnection()
{
global $servername, $dbname, $username, $password;
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
+ $conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $conn;
} \ No newline at end of file