-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
33 lines (28 loc) · 1.06 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask, render_template, request, send_file, redirect, url_for
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import linkedin
import os
app = Flask(__name__)
# Configure WebDriver options for Chrome
options = Options()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--headless")
browser = webdriver.Chrome(options=options)
@app.route("/")
def home():
return render_template("home.html")
@app.route("/search", methods=["GET", "POST"])
def search():
if request.method == "POST":
keyword = request.form.get("keyword")
if keyword:
linkedin.login(browser)
profiles = linkedin.scrape_multiple_profiles(browser, keyword)
filename = f"{keyword.replace(' ', '_')}_profiles.xlsx"
linkedin.profiles_to_excel(profiles, filename)
return send_file(filename, as_attachment=True, download_name=filename)
return render_template("search.html")
if __name__ == "__main__":
app.run(debug=True)