Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -41,9 +41,9 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
41 |
"device": "desktop",
|
42 |
"serp_type": "news",
|
43 |
"page": "1",
|
|
|
44 |
"verbatim": "0",
|
45 |
-
"gfilter": "0"
|
46 |
-
"num_result": "100" # num_result๋ก ์์
|
47 |
}
|
48 |
}
|
49 |
|
@@ -53,12 +53,22 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
53 |
"authorization": f"Bearer {API_KEY}"
|
54 |
}
|
55 |
|
|
|
|
|
|
|
56 |
try:
|
57 |
response = requests.post(url, json=payload, headers=headers)
|
|
|
|
|
|
|
|
|
58 |
response.raise_for_status()
|
59 |
return response.json()
|
60 |
except requests.RequestException as e:
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
def format_results_from_raw(results):
|
64 |
if isinstance(results, dict) and "error" in results:
|
|
|
41 |
"device": "desktop",
|
42 |
"serp_type": "news",
|
43 |
"page": "1",
|
44 |
+
"num": "10", # API ์ ํ์ ๋ง์ถฐ ์์
|
45 |
"verbatim": "0",
|
46 |
+
"gfilter": "0"
|
|
|
47 |
}
|
48 |
}
|
49 |
|
|
|
53 |
"authorization": f"Bearer {API_KEY}"
|
54 |
}
|
55 |
|
56 |
+
# ๋๋ฒ๊น
์ ์ํ ์์ฒญ ๋ด์ฉ ์ถ๋ ฅ
|
57 |
+
print("Request payload:", json.dumps(payload, indent=2))
|
58 |
+
|
59 |
try:
|
60 |
response = requests.post(url, json=payload, headers=headers)
|
61 |
+
# ๋๋ฒ๊น
์ ์ํ ์๋ต ๋ด์ฉ ์ถ๋ ฅ
|
62 |
+
print("Response status:", response.status_code)
|
63 |
+
print("Response content:", response.text[:500]) # ์ฒ์ 500์๋ง ์ถ๋ ฅ
|
64 |
+
|
65 |
response.raise_for_status()
|
66 |
return response.json()
|
67 |
except requests.RequestException as e:
|
68 |
+
error_msg = f"Error: {str(e)}"
|
69 |
+
if hasattr(response, 'text'):
|
70 |
+
error_msg += f"\nResponse content: {response.text}"
|
71 |
+
return {"error": error_msg}
|
72 |
|
73 |
def format_results_from_raw(results):
|
74 |
if isinstance(results, dict) and "error" in results:
|