Skip to content

Commit 0a701fb

Browse files
committed
feat: scrape changesets
1 parent e630398 commit 0a701fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import fetch, { RequestInfo } from 'node-fetch';
22
import { JSDOM } from 'jsdom';
33
import { UnityChangeset } from './unityChangeset';
44

5+
const UNITY_ARCHIVE_URL = 'https://unity3d.com/get-unity/download/archive';
6+
57
const getDocumentFromUrl = async (archiveUrl: RequestInfo) => {
68
const response = await fetch(archiveUrl);
79
const html = await response.text();
@@ -35,3 +37,12 @@ export const getBetaChangeset = async (version: string): Promise<UnityChangeset>
3537
.filter(href => UnityChangeset.isValid(href))
3638
.map(href => UnityChangeset.createFromHref(href))[0];
3739
};
40+
41+
export const scrapeArchivedChangesets = async (): Promise<UnityChangeset[]> => {
42+
const document = await getDocumentFromUrl(UNITY_ARCHIVE_URL);
43+
44+
return Array.from(document.querySelectorAll('a[href]'))
45+
.map(a => a.getAttribute('href') as string)
46+
.filter(href => UnityChangeset.isValid(href))
47+
.map(href => UnityChangeset.createFromHref(href));
48+
};

0 commit comments

Comments
 (0)