error_log("APKHub scraper çalıştı!"); function apkhub_scrape_and_post() { $target_url = 'https://5play.org/en/android/games/'; $response = wp_remote_get($target_url); if (is_wp_error($response)) { error_log("Bağlantı hatası: " . $response->get_error_message()); return; } $body = wp_remote_retrieve_body($response); // Tüm oyun linklerini çek preg_match_all('/(.*?)<\/h1>/', $game_body, $title_match); preg_match('/
(.*?)<\/div>/s', $game_body, $desc_match); $title = sanitize_text_field($title_match[1] ?? ''); $description = wp_kses_post($desc_match[1] ?? ''); if (!$title) { error_log("Başlık alınamadı: $game_url"); continue; } $slug = sanitize_title($title); $existing = get_page_by_path($slug, OBJECT, 'post'); if ($existing) { error_log("Zaten var: $title"); continue; } wp_insert_post([ 'post_title' => $title, 'post_name' => $slug, 'post_content' => $description, 'post_status' => 'publish', 'post_type' => 'post', ]); error_log("Eklendi: $title"); } }