Bana Ait Kendim yaptım ama biraz acemice
import requests
from bs4 import BeautifulSoup

def get_google_rank(keyword, website):
try:
url = f"https://www.google.com.tr/search?q={keyword}"
headers = {'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36'}
response = requests.get(url, headers=headers)
response.raise_for_status()

soup = BeautifulSoup(response.text, 'html.parser')
search_results = soup.find_all('div', class_='g')

for i, result in enumerate(search_results):
link = result.find('a')['href']
if website in link:
return i + 1 # Sıralamaya geri dön (1'den)

return -1 # Site bulunamazsa -1 döndür

except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
return None

# Örnek kullanım
keywords = ['gaziantep haber','gaziantep son dakika','gaziantep gundem']
website = 'gazianteptutku.com' # sitenizi yazın

for keyword in keywords:
rank = get_google_rank(keyword, website)
if rank is not None:
if rank == -1:
print(f"{keyword}Sıralama yok")
else:
print(f"{keyword}Sıralamada No.{rank}")