Skip to content

Commit 1aafc69

Browse files
committed
fix(relocateme): fix remote job crawl problem
some items don't have location (remote jobs) and also relocation package info that cause this problem
1 parent a282097 commit 1aafc69

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

relocateme/crawler.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@ def relocatme_crawler(page):
88
all_jobs = []
99
for job in jobs:
1010
job_name = job.find(class_="job__title").get_text()
11-
job_title, job_location = job_name.strip('\n').split('\n')
11+
job_content = job_name.strip('\n').split('\n')
12+
job_title = job_content[0]
13+
try:
14+
job_location = job_content[1]
15+
except:
16+
job_location = 'Relocation or remote'
1217
job_preview = job.find(class_="job__preview").get_text()
1318
job_info = job.find(class_="job__info")
1419
job_company = job_info.find(class_="job__company").get_text().strip('\n')
15-
relocation_info = job_info.find(class_='relocation-package-wrapper').find_all('div')
16-
relocation_type = relocation_info[0].get_text().strip('\n')
17-
relocation_details = relocation_info[1].get_text().strip('\n').split('\n\n\n\n')
20+
try:
21+
relocation_info = job_info.find(class_='relocation-package-wrapper').find_all('div')
22+
relocation_type = relocation_info[0].get_text().strip('\n')
23+
relocation_details = relocation_info[1].get_text().strip('\n').split('\n\n\n\n')
24+
except:
25+
relocation_type = 'Advanced relocation package'
26+
relocation_details = 'Unknown'
27+
1828
job_tags = job.find(class_="job__tags_wrapper").get_text().strip('\n').split('\n')
1929
link = 'https://relocate.me/' + job.find(class_="job__title").find('a').attrs['href']
2030
try:

0 commit comments

Comments
 (0)