Created
April 29, 2026 09:33
-
-
Save manthankool/0c56628fadb799deaa21dc5162d26e68 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import requests | |
| import pandas as pd | |
| from datetime import date | |
| API_KEY = "scrapingdog-api-key" | |
| TARGET_URL = "scrapingdog.com" | |
| KEYWORDS = [ | |
| "best serp api", | |
| "google serp api", | |
| "best web scraping api", | |
| "best web scraping tools", | |
| "scrape google news with python" | |
| ] | |
| def check_rank(keyword, target): | |
| url = "https://api.scrapingdog.com/google" | |
| params = { | |
| "api_key": API_KEY, | |
| "query": keyword, | |
| "results": 10, | |
| "country": "us" | |
| } | |
| response = requests.get(url, params=params) | |
| data = response.json() | |
| organic = data.get("organic_results", []) | |
| for index, result in enumerate(organic): | |
| if target in result.get("link", ""): | |
| return index + 1 | |
| return None | |
| results = [] | |
| for kw in KEYWORDS: | |
| rank = check_rank(kw, TARGET_URL) | |
| status = f"Position {rank}" if rank else "Not in top 10" | |
| print(f"{kw} → {status}") | |
| results.append({ | |
| "date": date.today(), | |
| "keyword": kw, | |
| "rank": rank if rank else "N/A" | |
| }) | |
| df = pd.DataFrame(results) | |
| df.to_csv("rank_tracking.csv", index=False) | |
| print("Saved to rank_tracking.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment