Jay-2776 commited on
Commit
a92c739
·
verified ·
1 Parent(s): f7f4da3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -18,31 +18,37 @@ if not API_KEY:
18
  # ---------------- CORE LOGIC ----------------
19
  def check_domain_rank(keyword):
20
  """
21
- Checks keyword ranking for TARGET_DOMAIN.
22
- Stops immediately once domain is found.
23
- USA Google results only.
 
24
  """
25
 
26
  headers = {
27
- "Accept": "application/json"
 
28
  }
29
 
30
  for page in range(MAX_PAGES):
31
  params = {
32
  "engine": "google",
33
  "q": keyword,
34
- "api_key": API_KEY,
35
  "start": page * 10,
36
  "num": 10,
37
 
38
- # ---- FORCE USA RESULTS ----
39
  "gl": "us",
40
  "hl": "en",
41
  "location": "United States",
42
  "google_domain": "google.com"
43
  }
44
 
45
- response = requests.get(BASE_URL, params=params, headers=headers, timeout=30)
 
 
 
 
 
46
 
47
  if response.status_code != 200:
48
  return {
@@ -52,7 +58,7 @@ def check_domain_rank(keyword):
52
  "Position on Page": "Error",
53
  "Absolute Rank": "Error",
54
  "URL": None,
55
- "Title": response.text
56
  }
57
 
58
  data = response.json()
@@ -107,7 +113,7 @@ def run_bulk_keywords(text):
107
  return df, output_file
108
 
109
  # ---------------- UI ----------------
110
- with gr.Blocks(title="Domain Rank Checker (USA)") as demo:
111
  gr.Markdown("## 🔍 Domain Rank Checker — USA Google Results")
112
  gr.Markdown(
113
  "**Tracked domain:** https://www.rishabhsoft.com/\n\n"
@@ -121,7 +127,7 @@ with gr.Blocks(title="Domain Rank Checker (USA)") as demo:
121
  keyword_box = gr.Textbox(
122
  label="Keywords (one per line)",
123
  lines=10,
124
- placeholder="power apps development company\nenterprise software development"
125
  )
126
 
127
  run_btn = gr.Button("Check Rankings")
 
18
  # ---------------- CORE LOGIC ----------------
19
  def check_domain_rank(keyword):
20
  """
21
+ Checks ranking of TARGET_DOMAIN for a keyword
22
+ Uses HasData SERP API
23
+ USA Google results only
24
+ Stops once domain is found
25
  """
26
 
27
  headers = {
28
+ "Accept": "application/json",
29
+ "X-API-KEY": API_KEY
30
  }
31
 
32
  for page in range(MAX_PAGES):
33
  params = {
34
  "engine": "google",
35
  "q": keyword,
 
36
  "start": page * 10,
37
  "num": 10,
38
 
39
+ # Force USA Google
40
  "gl": "us",
41
  "hl": "en",
42
  "location": "United States",
43
  "google_domain": "google.com"
44
  }
45
 
46
+ response = requests.get(
47
+ BASE_URL,
48
+ headers=headers,
49
+ params=params,
50
+ timeout=30
51
+ )
52
 
53
  if response.status_code != 200:
54
  return {
 
58
  "Position on Page": "Error",
59
  "Absolute Rank": "Error",
60
  "URL": None,
61
+ "Title": f"API Error {response.status_code}: {response.text}"
62
  }
63
 
64
  data = response.json()
 
113
  return df, output_file
114
 
115
  # ---------------- UI ----------------
116
+ with gr.Blocks(title="Domain Rank Checker — USA Google Results") as demo:
117
  gr.Markdown("## 🔍 Domain Rank Checker — USA Google Results")
118
  gr.Markdown(
119
  "**Tracked domain:** https://www.rishabhsoft.com/\n\n"
 
127
  keyword_box = gr.Textbox(
128
  label="Keywords (one per line)",
129
  lines=10,
130
+ placeholder=".NET MAUI app development services\nenterprise software development"
131
  )
132
 
133
  run_btn = gr.Button("Check Rankings")