Update app.py
Browse files
app.py
CHANGED
|
@@ -69,12 +69,13 @@ def fetch_linkedin_links(query, api_key, applicant_name):
|
|
| 69 |
"""Fetches LinkedIn profile links using BrightData SERP scraping API."""
|
| 70 |
try:
|
| 71 |
url = "https://api.brightdata.com/request"
|
| 72 |
-
google_url = f"https://www.google.com/search?q={
|
| 73 |
|
| 74 |
payload = {
|
|
|
|
| 75 |
"url": google_url,
|
| 76 |
"method": "GET",
|
| 77 |
-
"country": "us",
|
| 78 |
"format": "raw",
|
| 79 |
"data_format": "html"
|
| 80 |
}
|
|
@@ -86,7 +87,6 @@ def fetch_linkedin_links(query, api_key, applicant_name):
|
|
| 86 |
|
| 87 |
response = requests.post(url, headers=headers, json=payload)
|
| 88 |
response.raise_for_status()
|
| 89 |
-
|
| 90 |
html = response.text
|
| 91 |
|
| 92 |
# Match standard LinkedIn profile URLs
|
|
@@ -102,7 +102,7 @@ def fetch_linkedin_links(query, api_key, applicant_name):
|
|
| 102 |
return None
|
| 103 |
except Exception as e:
|
| 104 |
st.error(f"Error fetching link for query '{query}': {e}")
|
| 105 |
-
return None
|
| 106 |
|
| 107 |
def process_file(file, api_key):
|
| 108 |
"""Processes the uploaded Excel file to fetch LinkedIn profile links."""
|
|
|
|
| 69 |
"""Fetches LinkedIn profile links using BrightData SERP scraping API."""
|
| 70 |
try:
|
| 71 |
url = "https://api.brightdata.com/request"
|
| 72 |
+
google_url = f"https://www.google.com/search?q={quote_plus(query)}"
|
| 73 |
|
| 74 |
payload = {
|
| 75 |
+
"zone": "serp_api2", # ✅ ADD THIS LINE to include working zone
|
| 76 |
"url": google_url,
|
| 77 |
"method": "GET",
|
| 78 |
+
"country": "us",
|
| 79 |
"format": "raw",
|
| 80 |
"data_format": "html"
|
| 81 |
}
|
|
|
|
| 87 |
|
| 88 |
response = requests.post(url, headers=headers, json=payload)
|
| 89 |
response.raise_for_status()
|
|
|
|
| 90 |
html = response.text
|
| 91 |
|
| 92 |
# Match standard LinkedIn profile URLs
|
|
|
|
| 102 |
return None
|
| 103 |
except Exception as e:
|
| 104 |
st.error(f"Error fetching link for query '{query}': {e}")
|
| 105 |
+
return None
|
| 106 |
|
| 107 |
def process_file(file, api_key):
|
| 108 |
"""Processes the uploaded Excel file to fetch LinkedIn profile links."""
|