Skip to content

Commit

Permalink
refactor: use named imports from cheerio
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja committed Sep 21, 2024
1 parent 1fa3c1a commit 07f914b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/lib/scrapers/downloads.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cheerio from "cheerio";
import { load } from "cheerio";

import { withBaseUrl } from "../utils";

Expand All @@ -14,7 +14,7 @@ export function getFinalDownloadUrl(downloadPageUrl: string) {
}

export function extractRedirectDownloadUrl(downloadPageHtml: string) {
const $ = cheerio.load(downloadPageHtml);
const $ = load(downloadPageHtml);
const downloadUrl = $(`a.downloadButton`).attr("href");
if (!downloadUrl) {
throw new Error("Could not find redirect download url");
Expand All @@ -23,7 +23,7 @@ export function extractRedirectDownloadUrl(downloadPageHtml: string) {
}

export function extractFinalDownloadUrl(downloadPageHtml: string) {
const $ = cheerio.load(downloadPageHtml);
const $ = load(downloadPageHtml);
const downloadUrl = $(`.card-with-tabs a[href]`).attr("href");
if (!downloadUrl) {
throw new Error("Could not find final download url");
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scrapers/variants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cheerio from "cheerio";
import { load } from "cheerio";
import { match } from "ts-pattern";

import { isNotNull } from "../../utils/typescript";
Expand All @@ -12,7 +12,7 @@ export function getVariants(variantsPageUrl: string) {
}

export function extractVariants(variantsPageHtml: string) {
const $ = cheerio.load(variantsPageHtml);
const $ = load(variantsPageHtml);

const table = $(".variants-table").first();
if (!table) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/scrapers/versions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cheerio from "cheerio";
import { load } from "cheerio";

import { isNotNull } from "../../utils/typescript";
import { withBaseUrl } from "../utils";
Expand All @@ -10,7 +10,7 @@ export function getVersions(repoPageUrl: string) {
}

export function extractVersions(versionsPageHtml: string) {
const $ = cheerio.load(versionsPageHtml);
const $ = load(versionsPageHtml);
const table = $('.listWidget:has(a[name="all_versions"])').first();
if (!table) {
throw new Error("Could not find versions table");
Expand Down

0 comments on commit 07f914b

Please sign in to comment.