seawolf2357 commited on
Commit
313e0d9
·
verified ·
1 Parent(s): 31bd5ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -22
app.py CHANGED
@@ -9,27 +9,26 @@ API_KEY = os.getenv("SERPHOUSE_API_KEY")
9
 
10
 
11
  COUNTRY_LOCATIONS = {
12
- "United States": "2643743", # London, UK (임시)
13
- "United Kingdom": "2643743", # London, UK
14
- "Canada": "6167865", # Toronto, Canada
15
- "Australia": "2147714", # Sydney, Australia
16
- "Germany": "2950159", # Berlin, Germany
17
- "France": "2988507", # Paris, France
18
- "Japan": "1850147", # Tokyo, Japan
19
- "South Korea": "1835848", # Seoul, South Korea
20
- "China": "1796236", # Shanghai, China
21
- "India": "1275339", # Mumbai, India
22
- "Brazil": "3448439", # Sao Paulo, Brazil
23
- "Mexico": "3530597", # Mexico City, Mexico
24
- "Russia": "524901", # Moscow, Russia
25
- "Italy": "3169070", # Rome, Italy
26
- "Spain": "3117735", # Madrid, Spain
27
- "Netherlands": "2759794", # Amsterdam, Netherlands
28
- "Singapore": "1880252", # Singapore
29
- "Hong Kong": "1819729" # 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
- "loc_id": COUNTRY_LOCATIONS.get(country, "2643743"), # 기본값을 London으로 설정
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()