Skip to content

Commit 45b21ec

Browse files
committed
docs:example
1 parent 1ba3d76 commit 45b21ec

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

examples/daily_auto_connect.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
""" Script to connect with 10 software engineers daily from random tech companies """
2+
3+
from staffspy import LinkedInAccount, DriverType, BrowserType
4+
import random
5+
import time
6+
from datetime import datetime
7+
import schedule
8+
9+
# List of tech companies to randomly choose from
10+
TECH_COMPANIES = [
11+
"microsoft",
12+
"google",
13+
"apple",
14+
"meta",
15+
"amazon",
16+
"netflix",
17+
"salesforce",
18+
"adobe",
19+
"intel",
20+
"nvidia",
21+
"oracle",
22+
"ibm",
23+
"vmware",
24+
"twitter",
25+
"linkedin",
26+
"airbnb",
27+
"uber",
28+
"stripe",
29+
"snowflake",
30+
"databricks",
31+
]
32+
33+
34+
def connect_with_staff():
35+
print(f"Starting connection run at {datetime.now()}")
36+
37+
# Initialize LinkedIn account
38+
account = LinkedInAccount(session_file="session.pkl", log_level=1)
39+
40+
# Choose a random company
41+
company = random.choice(TECH_COMPANIES)
42+
print(f"Selected company: {company}")
43+
44+
# Connect with 10 users
45+
account.scrape_staff(
46+
company_name=company,
47+
search_term="software engineer",
48+
max_results=10,
49+
extra_profile_data=True,
50+
connect=True,
51+
)
52+
53+
54+
if __name__ == "__main__":
55+
# Schedule to run once a day at 10 AM
56+
schedule.every().day.at("10:00").do(connect_with_staff)
57+
58+
# Run immediately on script start
59+
connect_with_staff()
60+
61+
# Keep the script running
62+
while True:
63+
schedule.run_pending()
64+
time.sleep(60)

0 commit comments

Comments
 (0)