Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,27 +9,26 @@ API_KEY = os.getenv("SERPHOUSE_API_KEY")
|
|
9 |
|
10 |
|
11 |
COUNTRY_LOCATIONS = {
|
12 |
-
"United States": "
|
13 |
-
"United Kingdom": "
|
14 |
-
"Canada": "
|
15 |
-
"Australia": "
|
16 |
-
"Germany": "
|
17 |
-
"France": "
|
18 |
-
"Japan": "
|
19 |
-
"South Korea": "
|
20 |
-
"China": "
|
21 |
-
"India": "
|
22 |
-
"Brazil": "
|
23 |
-
"Mexico": "
|
24 |
-
"Russia": "
|
25 |
-
"Italy": "
|
26 |
-
"Spain": "
|
27 |
-
"Netherlands": "
|
28 |
-
"Singapore": "
|
29 |
-
"Hong Kong": "
|
30 |
}
|
31 |
|
32 |
-
|
33 |
MAJOR_COUNTRIES = list(COUNTRY_LOCATIONS.keys())
|
34 |
|
35 |
|
@@ -40,7 +39,7 @@ def search_serphouse(query, country, page=1, num_result=10):
|
|
40 |
"data": {
|
41 |
"q": query,
|
42 |
"domain": "google.com",
|
43 |
-
"
|
44 |
"lang": "en",
|
45 |
"device": "desktop",
|
46 |
"serp_type": "news",
|
@@ -59,8 +58,8 @@ def search_serphouse(query, country, page=1, num_result=10):
|
|
59 |
|
60 |
try:
|
61 |
response = requests.post(url, json=payload, headers=headers)
|
62 |
-
print("Request payload:", json.dumps(payload, indent=2))
|
63 |
-
print("Response status:", response.status_code)
|
64 |
|
65 |
response.raise_for_status()
|
66 |
return response.json()
|
|
|
9 |
|
10 |
|
11 |
COUNTRY_LOCATIONS = {
|
12 |
+
"United States": "United States",
|
13 |
+
"United Kingdom": "United Kingdom",
|
14 |
+
"Canada": "Canada",
|
15 |
+
"Australia": "Australia",
|
16 |
+
"Germany": "Germany",
|
17 |
+
"France": "France",
|
18 |
+
"Japan": "Japan",
|
19 |
+
"South Korea": "South Korea",
|
20 |
+
"China": "China",
|
21 |
+
"India": "India",
|
22 |
+
"Brazil": "Brazil",
|
23 |
+
"Mexico": "Mexico",
|
24 |
+
"Russia": "Russia",
|
25 |
+
"Italy": "Italy",
|
26 |
+
"Spain": "Spain",
|
27 |
+
"Netherlands": "Netherlands",
|
28 |
+
"Singapore": "Singapore",
|
29 |
+
"Hong Kong": "Hong Kong"
|
30 |
}
|
31 |
|
|
|
32 |
MAJOR_COUNTRIES = list(COUNTRY_LOCATIONS.keys())
|
33 |
|
34 |
|
|
|
39 |
"data": {
|
40 |
"q": query,
|
41 |
"domain": "google.com",
|
42 |
+
"loc": COUNTRY_LOCATIONS.get(country, "United States"), # loc 사용
|
43 |
"lang": "en",
|
44 |
"device": "desktop",
|
45 |
"serp_type": "news",
|
|
|
58 |
|
59 |
try:
|
60 |
response = requests.post(url, json=payload, headers=headers)
|
61 |
+
print("Request payload:", json.dumps(payload, indent=2))
|
62 |
+
print("Response status:", response.status_code)
|
63 |
|
64 |
response.raise_for_status()
|
65 |
return response.json()
|