Aşağıda vereceğim kodda kendimce bir şeyler denedim ancak google haritalar da, adresin ve telefonun doğru class'ını bulamadım. Belki yapabilen arkadaşlar olur geliştirip paylaşırlar.
Python:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service
import pandas as pd
import time
def get_search_results(driver, business_type, city, district):
driver.get("https://www.google.com/maps")
time.sleep(3)
search_box = driver.find_element(By.ID, "searchboxinput")
search_query = f"{business_type} {district}, {city}"
search_box.send_keys(search_query)
search_box.send_keys(Keys.RETURN)
time.sleep(5)
places = driver.find_elements(By.CLASS_NAME, "Nv2PK")
results = []
for place in places:
try:
name = place.find_element(By.CLASS_NAME, "qBF1Pd").text
address = place.find_element(By.CLASS_NAME, "OyjIsf").text
# Telefon numarasını ekle
try:
phone = place.find_element(By.CLASS_NAME, "W4Efsd").text
except:
phone = "Telefon bulunamadı"
results.append({"İsim": name, "Adres": address, "Telefon": phone})
except Exception as e:
print(f"Hata: {e}")
return results
def save_to_excel(data, filename="sonuclar.xlsx"):
df = pd.DataFrame(data)
df.to_excel(filename, index=False)
print(f"Sonuçlar {filename} dosyasına kaydedildi.")
def main():
print("Hoş geldiniz! Lütfen arama bilgilerini girin.")
business_type = input("İşletme türü: ")
city = input("Şehir: ")
district = input("İlçe: ")
driver_path = r"chromedriver.exe"
service = Service(driver_path)
driver = webdriver.Chrome(service=service)
try:
results = get_search_results(driver, business_type, city, district)
if results:
save_to_excel(results)
else:
print("Hiçbir sonuç bulunamadı.")
except Exception as e:
print(f"Bir hata oluştu: {e}")
finally:
driver.quit()
if __name__ == "__main__":
main()

