Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,8 @@ import tempfile
|
|
| 7 |
from jina import Flow, Executor, requests as jina_requests, Document
|
| 8 |
|
| 9 |
ZYLALABS_API_KEY = os.environ.get("ZYLALABS_API_KEY")
|
|
|
|
|
|
|
| 10 |
DASHBOARD_PASSWORD = os.environ.get("DASHBOARD_PASSWORD", "1984")
|
| 11 |
|
| 12 |
# Your existing Facebook scraping functions here
|
|
@@ -59,6 +61,37 @@ def jina_processor_interface(csv_file, password):
|
|
| 59 |
except Exception as e:
|
| 60 |
return f"An error occurred: {str(e)}", None, None
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
facebook_interface = gr.Interface(
|
| 63 |
fn=facebook_scraper_interface,
|
| 64 |
inputs=[
|
|
@@ -89,7 +122,22 @@ jina_interface = gr.Interface(
|
|
| 89 |
description="This dashboard processes generic website URLs using Jina."
|
| 90 |
)
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
demo.launch(share=True)
|
|
|
|
| 7 |
from jina import Flow, Executor, requests as jina_requests, Document
|
| 8 |
|
| 9 |
ZYLALABS_API_KEY = os.environ.get("ZYLALABS_API_KEY")
|
| 10 |
+
LINKEDIN_API_KEY = "4961|7EdUlk3bRYlk7gLpqVkpcsar2hdO5oGT76W7O5C2"
|
| 11 |
+
LINKEDIN_API_ENDPOINT = "https://zylalabs.com/api/1511/linkedin+profile+scraper+api/1250/get+data"
|
| 12 |
DASHBOARD_PASSWORD = os.environ.get("DASHBOARD_PASSWORD", "1984")
|
| 13 |
|
| 14 |
# Your existing Facebook scraping functions here
|
|
|
|
| 61 |
except Exception as e:
|
| 62 |
return f"An error occurred: {str(e)}", None, None
|
| 63 |
|
| 64 |
+
def get_linkedin_info(df):
|
| 65 |
+
def process_profile(url):
|
| 66 |
+
payload = {
|
| 67 |
+
"url": url,
|
| 68 |
+
"api_key": LINKEDIN_API_KEY,
|
| 69 |
+
}
|
| 70 |
+
response = requests.get(LINKEDIN_API_ENDPOINT, params=payload)
|
| 71 |
+
data = response.json()
|
| 72 |
+
return {
|
| 73 |
+
"Profile URL": url,
|
| 74 |
+
"Name": data["fullName"],
|
| 75 |
+
"Followers": data["followers"]["numberOfFollowers"],
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return pd.DataFrame([process_profile(url) for url in df['Profile URL']])
|
| 79 |
+
|
| 80 |
+
def linkedin_scraper_interface(csv_file, password):
|
| 81 |
+
if password != DASHBOARD_PASSWORD:
|
| 82 |
+
return "Incorrect Password", None, None
|
| 83 |
+
|
| 84 |
+
try:
|
| 85 |
+
df = pd.read_csv(csv_file.name, names=['Profile URL'], header=None)
|
| 86 |
+
output_df = get_linkedin_info(df)
|
| 87 |
+
|
| 88 |
+
with tempfile.NamedTemporaryFile(mode="w+", suffix=".csv", delete=False) as temp_file:
|
| 89 |
+
output_df.to_csv(temp_file.name, index=False)
|
| 90 |
+
|
| 91 |
+
return "Done", temp_file.name, output_df.head().to_string()
|
| 92 |
+
except Exception as e:
|
| 93 |
+
return f"An error occurred: {str(e)}", None, None
|
| 94 |
+
|
| 95 |
facebook_interface = gr.Interface(
|
| 96 |
fn=facebook_scraper_interface,
|
| 97 |
inputs=[
|
|
|
|
| 122 |
description="This dashboard processes generic website URLs using Jina."
|
| 123 |
)
|
| 124 |
|
| 125 |
+
linkedin_interface = gr.Interface(
|
| 126 |
+
fn=linkedin_scraper_interface,
|
| 127 |
+
inputs=[
|
| 128 |
+
gr.File(label="Input CSV File (must be CSV File with LinkedIn URLs)"),
|
| 129 |
+
gr.Textbox(label="Enter Dashboard Password", type="password")
|
| 130 |
+
],
|
| 131 |
+
outputs=[
|
| 132 |
+
gr.Textbox(label="Completion Status"),
|
| 133 |
+
gr.File(label="Download Scraped Data"),
|
| 134 |
+
gr.Textbox(label="Scraped Data Preview")
|
| 135 |
+
],
|
| 136 |
+
title="LinkedIn Scraper Dashboard",
|
| 137 |
+
description="This dashboard scrapes data from LinkedIn profiles using the Zylalabs API."
|
| 138 |
+
)
|
| 139 |
+
|
| 140 |
+
demo = gr.TabbedInterface([facebook_interface, jina_interface, linkedin_interface], ["Facebook Scraper", "Generic Website Processor", "LinkedIn Scraper"])
|
| 141 |
|
| 142 |
if __name__ == "__main__":
|
| 143 |
demo.launch(share=True)
|