Skip to content

Commit c1d2f0e

Browse files
update rit linkedin search jobs implementation messages
Signed-off-by: GuillaumeFalourd <guillaume.falourd@zup.com.br>
1 parent 77a7a12 commit c1d2f0e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

linkedin/search/jobs/src/classes/scrap.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
import requests
33
import os
44
import time
5+
import random
56

67
from bs4 import BeautifulSoup as soup
78

89
def get_datas(job, city, job_link):
910
job_datas = [job_link]
1011
try:
1112
for retry in range(5):
12-
time.sleep(5)
13+
time.sleep(random.randint(1, 3))
1314
page_req = requests.get(
1415
url = job_link,
1516
headers = {'User-agent': f'{job}_{city} bot'}
1617
)
1718
if page_req.status_code == "429":
1819
print(f"\033[1;36m\n⚠️ Too many requests - Retrying with other IP...\033[0m")
1920
change_ip(random.randint(1, 30))
20-
time.sleep(3)
21+
time.sleep(random.randint(1, 3))
2122
continue
2223
else:
2324
page_req.raise_for_status()
2425
# Parse HTML
2526
job_soup = soup(page_req.text, 'html.parser')
2627
contents = job_soup.findAll('div', {'class': 'topcard__content-left'})[0:]
2728
if len(contents) == 0:
28-
time.sleep(3)
29+
time.sleep(random.randint(1, 3))
2930
continue
3031
else:
31-
print(f"\033[1;36m\n⚠️ Couldn't retrieve all datas for the job link: {job_link}\033[0m")
32+
# Couldn't retrieve all datas for the job
3233
break
3334

3435
if len(contents) != 0:
@@ -48,7 +49,7 @@ def get_datas(job, city, job_link):
4849

4950
# Scraping Job Title
5051
for title in content.findAll('h1', {'class': 'topcard__title'})[0:]:
51-
print(f'\033[0;32m📌 {title.text}\033[0m', f'\033[1;33m- {org}\033[0m')
52+
print(f'\n\033[0;32m📌 {title.text}\033[0m', f'\033[1;33m- {org}\033[0m')
5253
job_datas.append(title.text.replace(',', '.'))
5354

5455
for location in content.findAll('span', {'class': 'topcard__flavor topcard__flavor--bullet'})[0:]:
@@ -80,9 +81,9 @@ def get_datas(job, city, job_link):
8081
for criteria in job_soup.findAll('span', {'class': 'job-criteria__text job-criteria__text--criteria'})[:4]:
8182
job_datas.append(criteria.text)
8283
else:
83-
print(f"\033[1;36m⚠️ Saving (only) the job link on the CSV file.\033[0m")
84+
print(f"\n\033[1;36m⚠️ Saving (only) the job link on the CSV file.\033[0m")
8485

85-
print(f"\033[0;34mExtracted Datas: {job_datas} \033[0m")
86+
# print(f"\033[0;34mExtracted Datas: {job_datas} \033[0m")
8687

8788
if len(job_datas) < 10:
8889
fill_number = 10 - len(job_datas)

linkedin/search/jobs/src/formula/formula.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def run(city, profession, send_email, email_receiver, sendgrid_api_key, sendgrid
2929
if len(job_links) == 0:
3030
print(f"\033[1;36m\n⚠️ Couldn't extract job links list from LinkedIn, try again later!\033[0m")
3131
else:
32-
print(f'\033[1;33m\n🕵️ There are {len(job_links)} available {job} jobs in {city.capitalize()}.\n\033[0m')
32+
print(f'\033[1;33m\n🕵️ {len(job_links)} recent {job} jobs identified in {city.capitalize()}.\n\033[0m')
3333

3434
# Extract Datas into a CSV file
3535
csv_filename = csv.filename(job, city)

0 commit comments

Comments
 (0)