@chrisdothtml/job-scraper 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/cache.d.ts +64 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +146 -0
- package/dist/cache.js.map +1 -0
- package/dist/companies.d.ts +89 -0
- package/dist/companies.d.ts.map +1 -0
- package/dist/companies.js +244 -0
- package/dist/companies.js.map +1 -0
- package/dist/companies.seed.d.ts +9 -0
- package/dist/companies.seed.d.ts.map +1 -0
- package/dist/companies.seed.js +455 -0
- package/dist/companies.seed.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +16 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +17 -0
- package/dist/paths.js.map +1 -0
- package/dist/platform/browser.d.ts +3 -0
- package/dist/platform/browser.d.ts.map +1 -0
- package/dist/platform/browser.js +103 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/node.d.ts +3 -0
- package/dist/platform/node.d.ts.map +1 -0
- package/dist/platform/node.js +106 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/types.d.ts +46 -0
- package/dist/platform/types.d.ts.map +1 -0
- package/dist/platform/types.js +2 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/resolve.d.ts +89 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +379 -0
- package/dist/resolve.js.map +1 -0
- package/dist/scrapers/AshbyScraper.d.ts +16 -0
- package/dist/scrapers/AshbyScraper.d.ts.map +1 -0
- package/dist/scrapers/AshbyScraper.js +207 -0
- package/dist/scrapers/AshbyScraper.js.map +1 -0
- package/dist/scrapers/GitHubScraper.d.ts +8 -0
- package/dist/scrapers/GitHubScraper.d.ts.map +1 -0
- package/dist/scrapers/GitHubScraper.js +61 -0
- package/dist/scrapers/GitHubScraper.js.map +1 -0
- package/dist/scrapers/GoogleScraper.d.ts +8 -0
- package/dist/scrapers/GoogleScraper.d.ts.map +1 -0
- package/dist/scrapers/GoogleScraper.js +83 -0
- package/dist/scrapers/GoogleScraper.js.map +1 -0
- package/dist/scrapers/GreenhouseScraper.d.ts +28 -0
- package/dist/scrapers/GreenhouseScraper.d.ts.map +1 -0
- package/dist/scrapers/GreenhouseScraper.js +68 -0
- package/dist/scrapers/GreenhouseScraper.js.map +1 -0
- package/dist/scrapers/LeverScraper.d.ts +13 -0
- package/dist/scrapers/LeverScraper.d.ts.map +1 -0
- package/dist/scrapers/LeverScraper.js +58 -0
- package/dist/scrapers/LeverScraper.js.map +1 -0
- package/dist/scrapers/NetflixScraper.d.ts +8 -0
- package/dist/scrapers/NetflixScraper.d.ts.map +1 -0
- package/dist/scrapers/NetflixScraper.js +60 -0
- package/dist/scrapers/NetflixScraper.js.map +1 -0
- package/dist/scrapers/NvidiaScraper.d.ts +8 -0
- package/dist/scrapers/NvidiaScraper.d.ts.map +1 -0
- package/dist/scrapers/NvidiaScraper.js +61 -0
- package/dist/scrapers/NvidiaScraper.js.map +1 -0
- package/dist/scrapers/RipplingScraper.d.ts +10 -0
- package/dist/scrapers/RipplingScraper.d.ts.map +1 -0
- package/dist/scrapers/RipplingScraper.js +64 -0
- package/dist/scrapers/RipplingScraper.js.map +1 -0
- package/dist/scrapers/Scraper.d.ts +134 -0
- package/dist/scrapers/Scraper.d.ts.map +1 -0
- package/dist/scrapers/Scraper.js +224 -0
- package/dist/scrapers/Scraper.js.map +1 -0
- package/dist/scrapers/ShopifyScraper.d.ts +16 -0
- package/dist/scrapers/ShopifyScraper.d.ts.map +1 -0
- package/dist/scrapers/ShopifyScraper.js +104 -0
- package/dist/scrapers/ShopifyScraper.js.map +1 -0
- package/dist/scrapers/SmartRecruitersScraper.d.ts +13 -0
- package/dist/scrapers/SmartRecruitersScraper.d.ts.map +1 -0
- package/dist/scrapers/SmartRecruitersScraper.js +66 -0
- package/dist/scrapers/SmartRecruitersScraper.js.map +1 -0
- package/dist/scrapers/UberScraper.d.ts +14 -0
- package/dist/scrapers/UberScraper.d.ts.map +1 -0
- package/dist/scrapers/UberScraper.js +94 -0
- package/dist/scrapers/UberScraper.js.map +1 -0
- package/dist/scrapers/WorkableScraper.d.ts +12 -0
- package/dist/scrapers/WorkableScraper.d.ts.map +1 -0
- package/dist/scrapers/WorkableScraper.js +67 -0
- package/dist/scrapers/WorkableScraper.js.map +1 -0
- package/dist/scrapers/WorkdayScraper.d.ts +14 -0
- package/dist/scrapers/WorkdayScraper.d.ts.map +1 -0
- package/dist/scrapers/WorkdayScraper.js +85 -0
- package/dist/scrapers/WorkdayScraper.js.map +1 -0
- package/dist/scrapers/index.d.ts +41 -0
- package/dist/scrapers/index.d.ts.map +1 -0
- package/dist/scrapers/index.js +46 -0
- package/dist/scrapers/index.js.map +1 -0
- package/dist/search.d.ts +75 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +225 -0
- package/dist/search.js.map +1 -0
- package/dist/sniff.d.ts +43 -0
- package/dist/sniff.d.ts.map +1 -0
- package/dist/sniff.js +124 -0
- package/dist/sniff.js.map +1 -0
- package/dist/utils/misc.d.ts +15 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +31 -0
- package/dist/utils/misc.js.map +1 -0
- package/package.json +70 -0
package/dist/search.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { platform } from '#platform';
|
|
2
|
+
import { corsAwareFetch } from "./cache.js";
|
|
3
|
+
import { normalizeCompanyName, slugMatchesCompany } from "./companies.js";
|
|
4
|
+
import { scraperNames, scrapers } from "./scrapers/index.js";
|
|
5
|
+
import {} from "./scrapers/Scraper.js";
|
|
6
|
+
import { applyOverrides, time } from "./utils/misc.js";
|
|
7
|
+
const DEFAULTS = {
|
|
8
|
+
apiKey: null,
|
|
9
|
+
limit: 250,
|
|
10
|
+
period: 'month',
|
|
11
|
+
resultCount: 10,
|
|
12
|
+
resultTtl: 30 * time.day,
|
|
13
|
+
batchSize: 5,
|
|
14
|
+
};
|
|
15
|
+
let overrides = {};
|
|
16
|
+
/**
|
|
17
|
+
* Overrides the search settings for this process. Anything left out keeps
|
|
18
|
+
* falling back to the environment, then to the defaults above. Passing
|
|
19
|
+
* `undefined` for a key drops the override, restoring that fallback.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* configureSearch({ apiKey: 'abc123', limit: 5, period: 'day' });
|
|
23
|
+
*/
|
|
24
|
+
export function configureSearch(config) {
|
|
25
|
+
overrides = applyOverrides(overrides, config);
|
|
26
|
+
}
|
|
27
|
+
export function getSearchConfig() {
|
|
28
|
+
const { env } = platform;
|
|
29
|
+
const limit = Number(env('SERPAPI_SEARCH_LIMIT'));
|
|
30
|
+
const period = env('SERPAPI_SEARCH_PERIOD');
|
|
31
|
+
return {
|
|
32
|
+
...DEFAULTS,
|
|
33
|
+
apiKey: env('SERP_API_TOKEN') ||
|
|
34
|
+
env('SERPAPI_KEY') ||
|
|
35
|
+
env('SERPAPI_API_KEY') ||
|
|
36
|
+
DEFAULTS.apiKey,
|
|
37
|
+
...(Number.isFinite(limit) && limit > 0 ? { limit } : {}),
|
|
38
|
+
...(period === 'day' || period === 'month' ? { period } : {}),
|
|
39
|
+
...overrides,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Whether a web search is configured and has quota left */
|
|
43
|
+
export async function canSearch() {
|
|
44
|
+
const config = getSearchConfig();
|
|
45
|
+
if (!config.apiKey)
|
|
46
|
+
return false;
|
|
47
|
+
return (await readUsage(config)).count < config.limit;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Asks a web search which job board a company posts on, by scoping the query
|
|
51
|
+
* to the domains our scrapers serve. This is the fallback for companies
|
|
52
|
+
* whose board slug can't be guessed from their name, and the only way to
|
|
53
|
+
* find a Workday tenant, since those slugs aren't derivable at all.
|
|
54
|
+
*
|
|
55
|
+
* Returns an empty array when search isn't configured, is out of quota, or
|
|
56
|
+
* turns up nothing. It never throws for those reasons; callers treat search
|
|
57
|
+
* as an optional accelerator.
|
|
58
|
+
*/
|
|
59
|
+
export async function searchForBoards(companyName) {
|
|
60
|
+
const [result] = await searchForBoardsBatch([companyName]);
|
|
61
|
+
return result?.boards ?? [];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Looks up several companies at once. Their names are OR'd into a single
|
|
65
|
+
* query and the results attributed back by slug, so `batchSize` companies
|
|
66
|
+
* cost one search instead of one each.
|
|
67
|
+
*
|
|
68
|
+
* Anything already cached is answered without a query, and only the
|
|
69
|
+
* remainder is batched, so re-running a large list is nearly free.
|
|
70
|
+
*/
|
|
71
|
+
export async function searchForBoardsBatch(companyNames) {
|
|
72
|
+
const config = getSearchConfig();
|
|
73
|
+
const results = new Map();
|
|
74
|
+
const pending = [];
|
|
75
|
+
const cached = await readResults();
|
|
76
|
+
for (const companyName of companyNames) {
|
|
77
|
+
const record = cached[normalizeCompanyName(companyName)];
|
|
78
|
+
// a remembered result stands in for a search, empty or not
|
|
79
|
+
if (record && Date.now() - record.ts < config.resultTtl) {
|
|
80
|
+
results.set(companyName, record.boards);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
pending.push(companyName);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (pending.length > 0 && config.apiKey) {
|
|
87
|
+
for (let i = 0; i < pending.length; i += config.batchSize) {
|
|
88
|
+
const chunk = pending.slice(i, i + config.batchSize);
|
|
89
|
+
const found = await runSearch(chunk, config);
|
|
90
|
+
if (!found)
|
|
91
|
+
break; // out of quota; leave the rest unsearched
|
|
92
|
+
for (const [companyName, boards] of found)
|
|
93
|
+
results.set(companyName, boards);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return companyNames.map((companyName) => ({
|
|
97
|
+
companyName,
|
|
98
|
+
boards: results.get(companyName) ?? [],
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
// concurrent resolutions of the same company must not each spend a search
|
|
102
|
+
const inFlight = new Map();
|
|
103
|
+
/**
|
|
104
|
+
* Runs one query for a chunk of companies, and remembers the outcome for
|
|
105
|
+
* each, including the ones nothing was found for.
|
|
106
|
+
*/
|
|
107
|
+
function runSearch(chunk, config) {
|
|
108
|
+
const key = chunk.map(normalizeCompanyName).sort().join('|');
|
|
109
|
+
const existing = inFlight.get(key);
|
|
110
|
+
if (existing)
|
|
111
|
+
return existing;
|
|
112
|
+
const promise = (async () => {
|
|
113
|
+
const usage = await readUsage(config);
|
|
114
|
+
if (usage.count >= config.limit)
|
|
115
|
+
return null;
|
|
116
|
+
const domains = scraperNames
|
|
117
|
+
.flatMap((name) => [...scrapers[name].boardDomains])
|
|
118
|
+
.map((domain) => `site:${domain}`)
|
|
119
|
+
.join(' OR ');
|
|
120
|
+
const names = chunk.map((name) => `"${name}"`).join(' OR ');
|
|
121
|
+
const url = new URL('https://serpapi.com/search.json');
|
|
122
|
+
url.searchParams.set('engine', 'google');
|
|
123
|
+
url.searchParams.set('q', chunk.length > 1 ? `(${names}) (${domains})` : `${names} (${domains})`);
|
|
124
|
+
// one query covering several companies needs room for all of them
|
|
125
|
+
url.searchParams.set('num', String(chunk.length > 1 ? 100 : config.resultCount));
|
|
126
|
+
url.searchParams.set('api_key', config.apiKey);
|
|
127
|
+
let links;
|
|
128
|
+
try {
|
|
129
|
+
// counted before the response lands: a search that errors after being
|
|
130
|
+
// dispatched still spends quota
|
|
131
|
+
await writeUsage({ ...usage, count: usage.count + 1 });
|
|
132
|
+
const res = await corsAwareFetch(url);
|
|
133
|
+
if (!res.ok)
|
|
134
|
+
return null;
|
|
135
|
+
const data = (await res.json());
|
|
136
|
+
links = (data.organic_results ?? [])
|
|
137
|
+
.map(({ link }) => link)
|
|
138
|
+
.filter((link) => Boolean(link));
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
const found = new Map(chunk.map((companyName) => [companyName, []]));
|
|
144
|
+
for (const link of links) {
|
|
145
|
+
const parsed = parseResult(link);
|
|
146
|
+
if (!parsed)
|
|
147
|
+
continue;
|
|
148
|
+
// attribute the result to whichever company the slug resembles; a
|
|
149
|
+
// search for a widely name-dropped company returns other companies'
|
|
150
|
+
// boards, and those must not be attributed to anyone
|
|
151
|
+
const owner = chunk.find((companyName) => slugMatchesCompany(parsed.slug, companyName));
|
|
152
|
+
if (!owner)
|
|
153
|
+
continue;
|
|
154
|
+
const boards = found.get(owner);
|
|
155
|
+
if (!boards.some((board) => board.slug === parsed.slug)) {
|
|
156
|
+
boards.push(parsed);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
await rememberResults(found);
|
|
160
|
+
return found;
|
|
161
|
+
})().finally(() => inFlight.delete(key));
|
|
162
|
+
inFlight.set(key, promise);
|
|
163
|
+
return promise;
|
|
164
|
+
}
|
|
165
|
+
function parseResult(link) {
|
|
166
|
+
const url = URL.parse(link);
|
|
167
|
+
if (!url)
|
|
168
|
+
return null;
|
|
169
|
+
for (const scraper of scraperNames) {
|
|
170
|
+
if (scrapers[scraper].boardDomains.length === 0)
|
|
171
|
+
continue;
|
|
172
|
+
const parsed = scrapers[scraper].parseUrl(url);
|
|
173
|
+
if (parsed)
|
|
174
|
+
return { ...parsed, scraper, url: link };
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const resultsFile = platform.dataFile('search-results.json');
|
|
179
|
+
/** Everything previously searched for, keyed by normalized company name */
|
|
180
|
+
async function readResults() {
|
|
181
|
+
try {
|
|
182
|
+
return JSON.parse((await platform.readText(resultsFile)) ?? '{}');
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async function rememberResults(found) {
|
|
189
|
+
const results = await readResults();
|
|
190
|
+
const ts = Date.now();
|
|
191
|
+
for (const [companyName, boards] of found) {
|
|
192
|
+
// recorded even when empty: knowing a company turned up nothing is
|
|
193
|
+
// exactly what stops the next lookup spending another search
|
|
194
|
+
results[normalizeCompanyName(companyName)] = { boards, ts };
|
|
195
|
+
}
|
|
196
|
+
await platform.writeText(resultsFile, JSON.stringify(results, null, 2) + '\n');
|
|
197
|
+
}
|
|
198
|
+
/** Forgets remembered search results. Returns how many companies were dropped */
|
|
199
|
+
export async function clearSearchCache() {
|
|
200
|
+
const results = await readResults();
|
|
201
|
+
const count = Object.keys(results).length;
|
|
202
|
+
inFlight.clear();
|
|
203
|
+
await platform.writeText(resultsFile, '{}\n');
|
|
204
|
+
return count;
|
|
205
|
+
}
|
|
206
|
+
const usageFile = platform.dataFile('search-usage.json');
|
|
207
|
+
function currentPeriod(config) {
|
|
208
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
209
|
+
return config.period === 'day' ? date : date.slice(0, 7);
|
|
210
|
+
}
|
|
211
|
+
async function readUsage(config) {
|
|
212
|
+
const period = currentPeriod(config);
|
|
213
|
+
try {
|
|
214
|
+
const usage = JSON.parse((await platform.readText(usageFile)) ?? '');
|
|
215
|
+
// a new period starts the count over
|
|
216
|
+
if (usage.period === period)
|
|
217
|
+
return usage;
|
|
218
|
+
}
|
|
219
|
+
catch { }
|
|
220
|
+
return { period, count: 0 };
|
|
221
|
+
}
|
|
222
|
+
async function writeUsage(usage) {
|
|
223
|
+
await platform.writeText(usageFile, JSON.stringify(usage, null, 2) + '\n');
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,O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AAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAClC,CAAC;QACX,qCAAqC;QACrC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,KAAY;IACpC,MAAM,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/sniff.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ScraperName } from './scrapers/index.ts';
|
|
2
|
+
import { type ParsedUrl } from './scrapers/Scraper.ts';
|
|
3
|
+
export interface SniffedBoard extends ParsedUrl {
|
|
4
|
+
scraper: ScraperName;
|
|
5
|
+
/** How many times the page pointed at this board */
|
|
6
|
+
hits: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Finds the job boards a page points at, by running every URL in its markup
|
|
10
|
+
* through the scrapers' own URL parsing. Ordered by how often the page
|
|
11
|
+
* referenced each board, so an embedded board outranks a stray mention.
|
|
12
|
+
*
|
|
13
|
+
* This is what makes a company's own careers page usable as input: the page
|
|
14
|
+
* itself is bespoke, but the board it embeds leaves its slug in the markup.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findBoardsInPage(html: string): SniffedBoard[];
|
|
17
|
+
/**
|
|
18
|
+
* Reads the company a page belongs to out of its markup. Returns the
|
|
19
|
+
* candidates it found, best first, along with a careers-suffix-stripped form
|
|
20
|
+
* of each ("Pinterest Careers" also yields "Pinterest").
|
|
21
|
+
*/
|
|
22
|
+
export declare function findNamesInPage(html: string): string[];
|
|
23
|
+
export interface SniffedPage {
|
|
24
|
+
/** Boards the page points at, most-referenced first */
|
|
25
|
+
boards: SniffedBoard[];
|
|
26
|
+
/** Company names the page claims for itself, most trustworthy first */
|
|
27
|
+
names: string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether the browser refused to fetch the page (see `CorsError`), in
|
|
30
|
+
* which case the empty results say nothing about the page itself
|
|
31
|
+
*/
|
|
32
|
+
blocked: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fetches a careers page and reports both the boards it embeds and the
|
|
36
|
+
* company it names itself after. Returns empty results when the page can't
|
|
37
|
+
* be fetched: plenty of careers sites sit behind a bot challenge, so
|
|
38
|
+
* sniffing is strictly a best-effort step.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sniffPage(url: string): Promise<SniffedPage>;
|
|
41
|
+
/** Fetches a careers page and reports the boards it embeds */
|
|
42
|
+
export declare function sniffBoards(url: string): Promise<SniffedBoard[]>;
|
|
43
|
+
//# sourceMappingURL=sniff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniff.d.ts","sourceRoot":"","sources":["../src/sniff.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,OAAO,EAAE,WAAW,CAAC;IACrB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;CACd;AASD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CA6B7D;AAgBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAgBtD;AAED,MAAM,WAAW,WAAW;IAC1B,uDAAuD;IACvD,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,uEAAuE;IACvE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmBjE;AAED,8DAA8D;AAC9D,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAEtE"}
|
package/dist/sniff.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { cachedFetch, CorsError } from "./cache.js";
|
|
2
|
+
import { scraperNames, scrapers } from "./scrapers/index.js";
|
|
3
|
+
import {} from "./scrapers/Scraper.js";
|
|
4
|
+
import { time } from "./utils/misc.js";
|
|
5
|
+
// URLs as they appear in markup: script/link hrefs, iframe srcs, inline JS
|
|
6
|
+
const URL_PATTERN = /https?:\/\/[a-z0-9.-]+\.[a-z]{2,}(?:\/[^\s"'<>()\\]*)?/gi;
|
|
7
|
+
// a page can mention a board it doesn't use (a careers blog linking a job at
|
|
8
|
+
// another company, say), so cap how much of it we're willing to believe
|
|
9
|
+
const MAX_HTML = 2_000_000;
|
|
10
|
+
/**
|
|
11
|
+
* Finds the job boards a page points at, by running every URL in its markup
|
|
12
|
+
* through the scrapers' own URL parsing. Ordered by how often the page
|
|
13
|
+
* referenced each board, so an embedded board outranks a stray mention.
|
|
14
|
+
*
|
|
15
|
+
* This is what makes a company's own careers page usable as input: the page
|
|
16
|
+
* itself is bespoke, but the board it embeds leaves its slug in the markup.
|
|
17
|
+
*/
|
|
18
|
+
export function findBoardsInPage(html) {
|
|
19
|
+
const found = new Map();
|
|
20
|
+
for (const match of html.slice(0, MAX_HTML).matchAll(URL_PATTERN)) {
|
|
21
|
+
const url = URL.parse(match[0]);
|
|
22
|
+
if (!url)
|
|
23
|
+
continue;
|
|
24
|
+
for (const scraper of scraperNames) {
|
|
25
|
+
// only boards that serve many companies can be identified this way;
|
|
26
|
+
// a single-company scraper would match its own marketing links
|
|
27
|
+
if (scrapers[scraper].boardDomains.length === 0)
|
|
28
|
+
continue;
|
|
29
|
+
const parsed = scrapers[scraper].parseUrl(url);
|
|
30
|
+
if (!parsed)
|
|
31
|
+
continue;
|
|
32
|
+
const key = `${scraper}:${parsed.slug}`;
|
|
33
|
+
const existing = found.get(key);
|
|
34
|
+
if (existing) {
|
|
35
|
+
existing.hits++;
|
|
36
|
+
// a reference that carries a job id is more useful than one without
|
|
37
|
+
existing.jobId ??= parsed.jobId;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
found.set(key, { ...parsed, scraper, hits: 1 });
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return [...found.values()].sort((a, b) => b.hits - a.hits);
|
|
46
|
+
}
|
|
47
|
+
// how a page names the company running it, in descending order of trust.
|
|
48
|
+
// `og:site_name` and JSON-LD are written for machines; `<title>` is written
|
|
49
|
+
// for people and usually carries the job title too
|
|
50
|
+
const NAME_PATTERNS = [
|
|
51
|
+
/<meta[^>]+(?:property|name)=["']og:site_name["'][^>]+content=["']([^"']+)["']/i,
|
|
52
|
+
/<meta[^>]+content=["']([^"']+)["'][^>]+(?:property|name)=["']og:site_name["']/i,
|
|
53
|
+
/"hiringOrganization"\s*:\s*\{[^{}]*"name"\s*:\s*"((?:[^"\\]|\\.)+)"/i,
|
|
54
|
+
/<meta[^>]+name=["']application-name["'][^>]+content=["']([^"']+)["']/i,
|
|
55
|
+
];
|
|
56
|
+
// trailing words a careers site appends to its own name
|
|
57
|
+
const SITE_SUFFIX = /[\s|\u2013\u2014·-]*\b(careers?|jobs?|job board|hiring|talent|work(?:place)?|life at)\b[\s|\u2013\u2014·-]*$/i;
|
|
58
|
+
/**
|
|
59
|
+
* Reads the company a page belongs to out of its markup. Returns the
|
|
60
|
+
* candidates it found, best first, along with a careers-suffix-stripped form
|
|
61
|
+
* of each ("Pinterest Careers" also yields "Pinterest").
|
|
62
|
+
*/
|
|
63
|
+
export function findNamesInPage(html) {
|
|
64
|
+
const names = [];
|
|
65
|
+
for (const pattern of NAME_PATTERNS) {
|
|
66
|
+
const value = pattern.exec(html.slice(0, MAX_HTML))?.[1];
|
|
67
|
+
if (!value)
|
|
68
|
+
continue;
|
|
69
|
+
const name = decodeEntities(value).trim();
|
|
70
|
+
if (!name || name.length > 80)
|
|
71
|
+
continue;
|
|
72
|
+
names.push(name);
|
|
73
|
+
const stripped = name.replace(SITE_SUFFIX, '').trim();
|
|
74
|
+
if (stripped && stripped !== name)
|
|
75
|
+
names.push(stripped);
|
|
76
|
+
}
|
|
77
|
+
return [...new Set(names)];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Fetches a careers page and reports both the boards it embeds and the
|
|
81
|
+
* company it names itself after. Returns empty results when the page can't
|
|
82
|
+
* be fetched: plenty of careers sites sit behind a bot challenge, so
|
|
83
|
+
* sniffing is strictly a best-effort step.
|
|
84
|
+
*/
|
|
85
|
+
export async function sniffPage(url) {
|
|
86
|
+
try {
|
|
87
|
+
const res = await cachedFetch.call({ cacheTTL: time.day }, url, {
|
|
88
|
+
headers: {
|
|
89
|
+
// some careers sites serve a stub to non-browser agents
|
|
90
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0 Safari/537.36',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const html = await res.text();
|
|
94
|
+
return {
|
|
95
|
+
boards: findBoardsInPage(html),
|
|
96
|
+
names: findNamesInPage(html),
|
|
97
|
+
blocked: false,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
return { boards: [], names: [], blocked: err instanceof CorsError };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Fetches a careers page and reports the boards it embeds */
|
|
105
|
+
export async function sniffBoards(url) {
|
|
106
|
+
return (await sniffPage(url)).boards;
|
|
107
|
+
}
|
|
108
|
+
const ENTITIES = {
|
|
109
|
+
amp: '&',
|
|
110
|
+
apos: "'",
|
|
111
|
+
gt: '>',
|
|
112
|
+
lt: '<',
|
|
113
|
+
nbsp: ' ',
|
|
114
|
+
quot: '"',
|
|
115
|
+
};
|
|
116
|
+
function decodeEntities(value) {
|
|
117
|
+
return value.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi, (match, code) => {
|
|
118
|
+
if (code[0] !== '#')
|
|
119
|
+
return ENTITIES[code.toLowerCase()] ?? match;
|
|
120
|
+
const point = Number(code[1] === 'x' || code[1] === 'X' ? `0${code.slice(1)}` : code.slice(1));
|
|
121
|
+
return Number.isFinite(point) ? String.fromCodePoint(point) : match;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=sniff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sniff.js","sourceRoot":"","sources":["../src/sniff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQvC,2EAA2E;AAC3E,MAAM,WAAW,GAAG,0DAA0D,CAAC;AAE/E,6EAA6E;AAC7E,wEAAwE;AACxE,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE9C,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAClE,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC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number;
|
|
5
|
+
readonly hour: number;
|
|
6
|
+
readonly day: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function buildUrl(base: string, path: string, params: Record<string, string | number | boolean>): URL;
|
|
9
|
+
/**
|
|
10
|
+
* Merges user-supplied config over existing overrides, treating an explicit
|
|
11
|
+
* `undefined` as "drop this override" rather than "set it to undefined";
|
|
12
|
+
* without that, a cleared key would shadow the env/default fallback.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyOverrides<T extends object>(current: Partial<T>, incoming: Partial<T>): Partial<T>;
|
|
15
|
+
//# sourceMappingURL=misc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,eAAO,MAAM,IAAI;;;;;CAMb,CAAC;AAEL,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAChD,GAAG,CAML;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC,CASZ"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Readable time durations in milliseconds */
|
|
2
|
+
export const time = (() => {
|
|
3
|
+
const second = 1e3;
|
|
4
|
+
const minute = 60 * second;
|
|
5
|
+
const hour = 60 * minute;
|
|
6
|
+
const day = 24 * hour;
|
|
7
|
+
return { second, minute, hour, day };
|
|
8
|
+
})();
|
|
9
|
+
export function buildUrl(base, path, params) {
|
|
10
|
+
const url = new URL(path, base);
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
url.searchParams.set(key, String(value));
|
|
13
|
+
}
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Merges user-supplied config over existing overrides, treating an explicit
|
|
18
|
+
* `undefined` as "drop this override" rather than "set it to undefined";
|
|
19
|
+
* without that, a cleared key would shadow the env/default fallback.
|
|
20
|
+
*/
|
|
21
|
+
export function applyOverrides(current, incoming) {
|
|
22
|
+
const merged = { ...current };
|
|
23
|
+
for (const key of Object.keys(incoming)) {
|
|
24
|
+
if (incoming[key] === undefined)
|
|
25
|
+
delete merged[key];
|
|
26
|
+
else
|
|
27
|
+
merged[key] = incoming[key];
|
|
28
|
+
}
|
|
29
|
+
return merged;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=misc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/utils/misc.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE;IACxB,MAAM,MAAM,GAAG,GAAG,CAAC;IACnB,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAW,CAAC;AAChD,CAAC,CAAC,EAAE,CAAC;AAEL,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,IAAY,EACZ,MAAiD;IAEjD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAmB,EACnB,QAAoB;IAEpB,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAE9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAgB,EAAE,CAAC;QACvD,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;;YAC/C,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chrisdothtml/job-scraper",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A collection of job board scrapers, plus utilities that resolve a scraper for a company on the fly",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jobs",
|
|
7
|
+
"scraper",
|
|
8
|
+
"ats",
|
|
9
|
+
"greenhouse",
|
|
10
|
+
"ashby",
|
|
11
|
+
"lever",
|
|
12
|
+
"workday"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/chrisdothtml/job-scraper.git"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"packageManager": "yarn@4.13.0",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"imports": {
|
|
28
|
+
"#platform": {
|
|
29
|
+
"job-scraper-source": {
|
|
30
|
+
"node": "./src/platform/node.ts",
|
|
31
|
+
"default": "./src/platform/browser.ts"
|
|
32
|
+
},
|
|
33
|
+
"node": "./dist/platform/node.js",
|
|
34
|
+
"default": "./dist/platform/browser.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"// checks": "----------------------------",
|
|
47
|
+
"lint": "prettier --check .",
|
|
48
|
+
"lint-fix": "prettier --write . | grep -v ' (unchanged)'",
|
|
49
|
+
"test": "./bin/tsn --test './src/__tests__/**/*.test.ts'",
|
|
50
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p site",
|
|
51
|
+
"// build": "-----------------------------",
|
|
52
|
+
"bake-version": "./bin/tsn src/scripts/bakeVersion.ts",
|
|
53
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && yarn bake-version",
|
|
54
|
+
"prepack": "yarn build",
|
|
55
|
+
"// site": "------------------------------",
|
|
56
|
+
"site:build": "./bin/tsn site/build.ts",
|
|
57
|
+
"site:dev": "./bin/tsn site/build.ts --dev"
|
|
58
|
+
},
|
|
59
|
+
"volta": {
|
|
60
|
+
"node": "25.2.1",
|
|
61
|
+
"yarn": "4.13.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^22.18.0",
|
|
65
|
+
"esbuild": "^0.28.2",
|
|
66
|
+
"prettier": "^3.6.2",
|
|
67
|
+
"prettier-plugin-sh": "^0.18.0",
|
|
68
|
+
"typescript": "^5.9.2"
|
|
69
|
+
}
|
|
70
|
+
}
|