ARŞİF BÖLGESİ GİRİŞ LİNKİ
import requests from bs4 import BeautifulSoup from pymongo import MongoClient import json
def tjk_veri_cek(): url = "https://www.tjk.org/TR/YarisSever/Info/Page/GunlukYarisProgrami" response = requests.get(url) if response.status_code != 200: print("Veri çekme başarısız!") return None
soup = BeautifulSoup(response.text, 'html.parser')
kosular = [] # Tüm yarış verileri burada saklanacak
for kosu in soup.select(".raceRow"): # HTML'deki yarış satırlarını seç
sehir = kosu.select_one(".city").text.strip()
tarih = kosu.select_one(".date").text.strip()
mesafe = int(kosu.select_one(".distance").text.strip().replace("m", ""))
agf_ilk_5 = [float(x.text.strip().replace(",", ".")) for x in kosu.select(".agf")[:5]]
kazanan_ganyan = float(kosu.select_one(".winnerGanyan").text.strip().replace(",", "."))
kosular.append({
"sehir": sehir,
"tarih": tarih,
"mesafe": mesafe,
"agf_ilk_5": agf_ilk_5,
"kazanan_ganyan": kazanan_ganyan
})
return kosular
def mongo_kaydet(veri): client = MongoClient("mongodb://localhost:27017/") db = client["at_yarisi"] collection = db["kosu_verileri"] collection.insert_many(veri) print("Veriler MongoDB'ye kaydedildi!")
def analiz_ve_goster(): client = MongoClient("mongodb://localhost:27017/") db = client["at_yarisi"] collection = db["kosu_verileri"]
for veri in collection.find():
print(json.dumps(veri, indent=4, ensure_ascii=False))
if name == "main": kosu_verileri = tjk_veri_cek() if kosu_verileri: mongo_kaydet(kosu_verileri) analiz_ve_goster()