dms-scrape 0.2.1 → 0.3.0

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.
@@ -1,19 +0,0 @@
1
- import { justScrape } from "./justScrape.mjs";
2
- export async function fetchAndScrape(link) {
3
- var response;
4
- try {
5
- // if (
6
- // link.includes("digitimes") ||
7
- // link.includes("chinatimes") ||
8
- // link.includes("ctee") ||
9
- // link.includes("buzzorange")
10
- // ) {
11
- // return "Must use extension";
12
- // } else {
13
- response = await fetch(link);
14
- return justScrape(link, await response.text());
15
- // }
16
- } catch (error) {
17
- return error;
18
- }
19
- }
@@ -1,33 +0,0 @@
1
- // import { processHTML } from "./determineSource.mjs";
2
- import { filterContent } from "./filterContent.mjs";
3
- import { determineCategory } from "./determineCategory.mjs";
4
- import { determineSource } from "./determineSource.mjs";
5
- import * as cheerio from 'cheerio'
6
- export function justScrape(link, html) {
7
- try {
8
- const handlerFunction = determineSource(link);
9
- var scrapedContent =
10
- typeof handlerFunction == "function"
11
- ? handlerFunction(cheerio.load(html))
12
- : handlerFunction;
13
- if (scrapedContent["error"] == undefined) {
14
- scrapedContent["content"]
15
- ? (scrapedContent["content"] = filterContent(scrapedContent["content"]))
16
- : "";
17
-
18
- Array.isArray(scrapedContent["author"])
19
- ? (scrapedContent["author"] = scrapedContent["author"].toString())
20
- : "";
21
- Array.isArray(scrapedContent["date"])
22
- ? (scrapedContent["date"] = scrapedContent["date"].toString())
23
- : "";
24
- scrapedContent["category"] = determineCategory(scrapedContent["title"]);
25
- scrapedContent["url"] = link;
26
- scrapedContent["content"] = scrapedContent["content"].join("\n\n");
27
- }
28
-
29
- return scrapedContent;
30
- } catch (error) {
31
- return error;
32
- }
33
- }
@@ -1,6 +0,0 @@
1
- export function handleUnsupported(url) {
2
- return {
3
- error: "unsupported link",
4
- url: url
5
- }
6
- }