<?php
ini_set('error_reporting',8191);
ini_set('display_errors',1);
include "../../../bots/loader.php";
include "../../translators/swedish/loaderswedish.php";
$ts = new TranslateSwedish("","","");
$db = new SwedishDatabaseHandler($ts);
$words = $db->selectUnconvertedWords(10);
foreach($words as $phrase){
$phrase = urlencode($phrase['word']);
$phrase = str_replace("+"," ", $phrase);
$curl = new MiniCurl("https://glosbe.com/de/sv/".$phrase);
echo $page= $curl->getData();
preg_match('$<strong class=" phr">(.*)</strong>$',$page, $matches, PREG_OFFSET_CAPTURE);
if(!isset($matches[1][0])) {
preg_match('$<div class="phr text-info">(.*)</div>$',$page, $matches, PREG_OFFSET_CAPTURE);
}
$translated="";
if( $matches[1][0]!==NULL && strlen($matches[1][0]) <=100){
$translated = $matches[1][0];
}
echo "</br>".$translated;
$db->updateTranslation($phrase, $translated);
}
?>