Skip to content

Commit

Permalink
adjust jobsite details
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLLKong committed May 29, 2024
1 parent b147828 commit bb53928
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
9 changes: 4 additions & 5 deletions scrapers/jobs/puppet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { setTimeout } from 'node:timers/promises';
const BASE_URL = `https://www.newcomersjobcentre.ca/`;
const SELECTOR_TIMEOUT = 5000; // use for waiting for selectors
const PAGE_TIMEOUT = 60000; // use for page navigation
const PAGES_TO_SCRAPE = 5; // Don't need that much data. Just scrape the most recent few pages of jobs
const PAGES_TO_SCRAPE = 1; // Don't need that much data. Just scrape the most recent few pages of jobs

const device = {
userAgent: 'Mozilla/5.0 (Macintosh)', // set our fake user-agent
Expand Down Expand Up @@ -147,7 +147,8 @@ const scrapeJobs = async browser => {
const addressSplit = details[1].trim().split(',');
const addressLocality = addressSplit[0].trim();
const addressRegion = addressRegionMap[addressSplit[1].trim()];
const employmentSubType = details[6];
const employment = details[6].split('-');
const employmentSubType = employment[0] + ' ' + employment[1];
const paySplit = details[7].split(' : ')[1].split(' ');
const minCompValue =
paySplit[0][1] === '$'
Expand Down Expand Up @@ -191,9 +192,7 @@ const scrapeJobs = async browser => {
);

const description = await sectionContentElement?.evaluate(node => {
const textContent = node.textContent.trim();

return textContent;
return node.innerHTML.split('<style>')[0];
});

jobDetailsObj['description'] = description;
Expand Down
2 changes: 1 addition & 1 deletion src/components/jobsite/jobListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function JobListCard({ colourTheme, item, onClick }) {
{item.addressLocality}, {item.addressRegion}
</div>
<div className="text-xs text-gray-400 dark:text-gray-300 mb-4">
{item.datePosted.split(' ').slice(2).join(' ')}
{new Date(item.datePosted).toDateString()}
</div>
</div>
<div className="flex justify-between">
Expand Down
17 changes: 12 additions & 5 deletions src/components/jobsite/jobdetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function JobDetail({ colourTheme, postingID, showJobPageBtn }) {
{jobDetail.hiringOrganization}
</p>
<div className="text-right text-sm text-gray-500 dark:text-gray-400 mt-1 lg:mt-0">
{jobDetail.datePosted}
{new Date(jobDetail.datePosted).toDateString()}
</div>
{showJobPageBtn && (
<Link
Expand All @@ -70,7 +70,12 @@ export default function JobDetail({ colourTheme, postingID, showJobPageBtn }) {
<div className="flex items-center gap-2">
<BriefcaseIcon className="w-5 h-5 text-gray-500 dark:text-gray-400" />
<span className="text-gray-500 dark:text-gray-400 titleCase">
{jobDetail.employmentSubType}, {jobDetail.employmentType}
{jobDetail.employmentSubType
? jobDetail.employmentSubType
: ''}
{jobDetail.employmentType
? `, ${jobDetail.employmentType}`
: ''}
</span>
</div>
<div className="flex items-center gap-2">
Expand All @@ -97,19 +102,21 @@ export default function JobDetail({ colourTheme, postingID, showJobPageBtn }) {
<div className="flex items-center gap-2">
<ClockIcon className="w-5 h-5 text-gray-500 dark:text-gray-400" />
<span className="text-gray-500 dark:text-gray-400">
{jobDetail.workHours}
{jobDetail.workHours ? `${jobDetail.workHours}` : 'N/A'}
</span>
</div>
<div className="flex items-center gap-2">
<CalendarIcon className="w-5 h-5 text-gray-500 dark:text-gray-400" />
<span className="text-gray-500 dark:text-gray-400">
{jobDetail.startTime}
{jobDetail.startTime ? `${jobDetail.startTime}` : 'N/A'}
</span>
</div>
<div className="flex items-center gap-2">
<UserIcon className="w-5 h-5 text-gray-500 dark:text-gray-400" />
<span className="text-gray-500 dark:text-gray-400">
{jobDetail.vacancies} vacancy
{jobDetail.vacancies
? `${jobDetail.vacancies} vacancy`
: 'N/A'}
</span>
</div>
</div>
Expand Down

0 comments on commit bb53928

Please sign in to comment.