Spaces:
Building
Building
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -40,17 +40,20 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
40 |
"data": {
|
41 |
"q": query,
|
42 |
"domain": "google.com",
|
43 |
-
"
|
|
|
44 |
"lang": "en",
|
45 |
"device": "desktop",
|
46 |
"serp_type": "news",
|
47 |
"page": str(page),
|
48 |
-
"verbatim": "
|
49 |
-
"
|
50 |
-
"
|
51 |
}
|
52 |
}
|
53 |
|
|
|
|
|
54 |
headers = {
|
55 |
"accept": "application/json",
|
56 |
"content-type": "application/json",
|
@@ -59,6 +62,8 @@ def search_serphouse(query, country, page=1, num_result=100):
|
|
59 |
|
60 |
try:
|
61 |
response = requests.post(url, json=payload, headers=headers)
|
|
|
|
|
62 |
response.raise_for_status()
|
63 |
return response.json()
|
64 |
except requests.RequestException as e:
|
|
|
40 |
"data": {
|
41 |
"q": query,
|
42 |
"domain": "google.com",
|
43 |
+
"loc": country, # ๊ตญ๊ฐ ์ด๋ฆ
|
44 |
+
"loc_id": COUNTRY_LOCATIONS.get(country, "1026201"), # loc_id
|
45 |
"lang": "en",
|
46 |
"device": "desktop",
|
47 |
"serp_type": "news",
|
48 |
"page": str(page),
|
49 |
+
"verbatim": "0", # ๋ฌธ์์ ๋ง๊ฒ ์์
|
50 |
+
"gfilter": "0", # ์ถ๊ฐ
|
51 |
+
"num": str(num_result)
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
print("Request payload:", json.dumps(payload, indent=2)) # ๋๋ฒ๊น
์ ์ํ ์ถ๋ ฅ
|
56 |
+
|
57 |
headers = {
|
58 |
"accept": "application/json",
|
59 |
"content-type": "application/json",
|
|
|
62 |
|
63 |
try:
|
64 |
response = requests.post(url, json=payload, headers=headers)
|
65 |
+
print("Response status:", response.status_code) # ๋๋ฒ๊น
์ ์ํ ์ถ๋ ฅ
|
66 |
+
print("Response content:", response.text) # ๋๋ฒ๊น
์ ์ํ ์ถ๋ ฅ
|
67 |
response.raise_for_status()
|
68 |
return response.json()
|
69 |
except requests.RequestException as e:
|