Created
November 24, 2017 14:41
-
-
Save webuti/74c5172ff08d797618a35097d82553a4 to your computer and use it in GitHub Desktop.
tdk parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$alfabe = 'abcçdefgğhiıjklmnoöprsştuüvyz'; | |
$db = new PDO("mysql:host=localhost;dbname=kelimeler;charset=utf8", "root", ""); | |
function tdkgetir($harf, $sayfa = 0) | |
{ | |
return file_get_contents('http://www.tdk.gov.tr/index.php?option=com_yazimkilavuzu&view=yazimkilavuzu&kategori1=yazim_listeli&ayn1=bas&kelime1=' . $harf . '&sayfa1=' . $sayfa); | |
} | |
function mbStringToArray($string) | |
{ | |
$strlen = mb_strlen($string); | |
while ($strlen) { | |
$array[] = mb_substr($string, 0, 1, "UTF-8"); | |
$string = mb_substr($string, 1, $strlen, "UTF-8"); | |
$strlen = mb_strlen($string); | |
} | |
return $array; | |
} | |
$alfabe = mbStringToArray($alfabe); | |
foreach ($alfabe as $harf) { | |
$data = tdkgetir($harf, 0); | |
preg_match_all('/option value="(.*?)"/i', $data, $option); | |
unset($option[1][0]); | |
unset($option[1][1]); | |
foreach ($option[1] as $sayfalar) { | |
$datar = tdkgetir($harf, $sayfalar); | |
preg_match_all('/kelime=(.*?)&/i', $datar, $bulunan); | |
foreach ($bulunan[1] as $yaz) { | |
$db->query("INSERT INTO kelime SET kelime = '" . $yaz . "'"); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment