-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmain.py
More file actions
84 lines (73 loc) · 2.74 KB
/
main.py
File metadata and controls
84 lines (73 loc) · 2.74 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from dotenv import load_dotenv
from job_scraper_utils import *
load_dotenv()
"""
List of countries url.
"""
nigeria = 'https://ng.indeed.com'
united_kingdom = 'https://uk.indeed.com'
united_states = 'https://www.indeed.com'
canada = 'https://ca.indeed.com'
germany = 'https://de.indeed.com'
australia = 'https://au.indeed.com'
south_africa = 'https://za.indeed.com'
sweden = 'https://se.indeed.com'
singapore = 'https://www.indeed.com.sg'
switzerland = 'https://www.indeed.ch'
united_arab_emirates = 'https://www.indeed.ae'
new_zealand = 'https://nz.indeed.com'
india = 'https://www.indeed.co.in'
france = 'https://www.indeed.fr'
italy = 'https://it.indeed.com'
spain = 'https://www.indeed.es'
japan = 'https://jp.indeed.com'
south_korea = 'https://kr.indeed.com'
brazil = 'https://www.indeed.com.br'
mexico = 'https://www.indeed.com.mx'
china = 'https://cn.indeed.com'
saudi_arabia = 'https://sa.indeed.com'
egypt = 'https://eg.indeed.com'
thailand = 'https://th.indeed.com'
vietnam = 'https://vn.indeed.com'
argentina = 'https://ar.indeed.com'
ireland = 'https://ie.indeed.com'
def main():
driver = configure_webdriver()
country = india
sender_email = os.getenv("SENDER_EMAIL")
receiver_email = os.getenv("RECEIVER_EMAIL")
password = os.getenv("PASSWORD")
job_position = 'web developer'
job_location = 'remote'
date_posted = 20
cleaned_df = None
try:
full_url = search_jobs(driver, country, job_position, job_location, date_posted)
df = scrape_job_data(driver, country)
if df.shape[0] == 1:
print("No results found. Something went wrong.")
subject = 'No Jobs Found on Indeed'
body = """
No jobs were found for the given search criteria.
Please consider the following:
1. Try adjusting your search criteria.
2. If you used English search keywords for non-English speaking countries,
it might return an empty result. Consider using keywords in the country's language.
3. Try more general keyword(s), check your spelling or replace abbreviations with the entire word
Feel free to try a manual search with this link and see for yourself:
Link {}
""".format(full_url)
send_email_empty(sender_email, receiver_email, subject, body, password)
else:
cleaned_df = clean_data(df)
# csv_file = save_csv(cleaned_df, job_position, job_location)
finally:
try:
send_email(cleaned_df, sender_email, receiver_email, job_position, job_location, password)
except Exception as e:
print(f"Error sending email: {e}")
finally:
pass
driver.quit()
if __name__ == "__main__":
main()