Skip to content

Commit c302d57

Browse files
committed
cron, email sender, pm2 daemon manager added
1 parent 975233b commit c302d57

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
LOCAL_PATH="/Users/keithhetrick/Desktop/VS-Code-Projects/web-scraper-test-2"
1+
LOCAL_PATH=/Users/keithhetrick/Desktop/VS-Code-Projects/web-scraper-test-2

googleWebScrapers/googleJobScraper/googleJobScraper.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,41 +58,53 @@ const getJobsData = async () => {
5858
// create PDF file
5959
const doc = new PDFDocument();
6060

61-
const file_Name = `dailyJobScraper-${new Date().getTime()}.pdf`;
62-
const file_Path = LOCAL_PATH;
61+
// dont show the time zone while using Date() in the file name
62+
const date = new Date().toLocaleDateString("en-us", {
63+
weekday: "long",
64+
year: "numeric",
65+
month: "short",
66+
day: "numeric",
67+
});
68+
69+
const time = new Date().toLocaleTimeString([], {
70+
hour: "2-digit",
71+
minute: "2-digit",
72+
});
73+
74+
const file_Name = `Daily Job Scraper - ${date} - ${time}.pdf`;
75+
const file_Path = `${LOCAL_PATH}/`;
6376

6477
// sanitize file name
65-
const full_FileName = (file_Path + file_Name)
66-
.replace(/:/g, "-")
67-
.replace(/,/g, "-")
68-
.replace(/ /g, "-");
78+
const full_FileName = file_Path + file_Name.replace(/:/g, "-");
79+
80+
console.log("FULL FILE NAME: ", full_FileName);
6981

7082
doc.pipe(fs.createWriteStream(full_FileName));
71-
doc.fontSize(20).text("Google Jobs Results", {
83+
doc.fontSize(18).text("Google Jobs Results", {
7284
align: "center",
7385
});
74-
doc.fontSize(12).text(`${new Date().toLocaleString()}`, {
86+
doc.fontSize(9).text(`${new Date().toLocaleString()}`, {
7587
align: "center",
7688
});
7789

7890
jobs_results.forEach((job) => {
79-
doc.fontSize(18).text(`\n Title: ${job.title}`, {
91+
doc.fontSize(12).text(`\n Title: ${job.title}`, {
8092
align: "left",
8193
width: 500,
8294
});
83-
doc.fontSize(15).text(`Company Name: ${job.company_name}`, {
95+
doc.fontSize(12).text(`Company Name: ${job.company_name}`, {
8496
align: "left",
8597
width: 500,
8698
});
87-
doc.fontSize(15).text(`Location: ${job.location}`, {
99+
doc.fontSize(12).text(`Location: ${job.location}`, {
88100
align: "left",
89101
width: 500,
90102
});
91-
doc.fontSize(15).text(`Via: ${job.via}`, {
103+
doc.fontSize(12).text(`Via: ${job.via}`, {
92104
align: "left",
93105
width: 500,
94106
});
95-
doc.fontSize(15).text(`Extensions: ${job.extensions}`, {
107+
doc.fontSize(12).text(`Extensions: ${job.extensions}`, {
96108
align: "left",
97109
width: 500,
98110
});
@@ -118,7 +130,7 @@ getJobsData();
118130
// ================== CRON SCHEDULER ====================== ||
119131
// ======================================================== //
120132

121-
cron.schedule("0 8 * * *", getJobsData, {
133+
cron.schedule("0 */2 * * *", getJobsData, {
122134
scheduled: true,
123135
timezone: "America/Chicago",
124136
});

0 commit comments

Comments
 (0)