dms-scrape 0.1.1 → 0.1.2
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/lib/determineCategory.mjs +18 -0
- package/lib/justScrape.mjs +2 -0
- package/package.json +1 -1
- package/sources/T1/UDNMoney.mjs +1 -1
- package/sources/T2/LTN3C.mjs +1 -1
- package/sources/T2/LTNEC.mjs +1 -1
- package/sources/T2/UDN.mjs +1 -1
- package/sources/T4/ETDAY.mjs +1 -1
- package/test.mjs +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function determineCategory(title) {
|
|
2
|
+
switch (true) {
|
|
3
|
+
case title.includes("高通"):
|
|
4
|
+
return "Qualcomm相關新聞";
|
|
5
|
+
|
|
6
|
+
case title.includes("聯發科"):
|
|
7
|
+
return "MediaTek相關新聞";
|
|
8
|
+
|
|
9
|
+
case title.includes("5G"):
|
|
10
|
+
return "無線通訊市場";
|
|
11
|
+
|
|
12
|
+
case title.includes("OPPO") || title.includes("PC"):
|
|
13
|
+
return "智慧型手機/消費性電子產品";
|
|
14
|
+
|
|
15
|
+
default:
|
|
16
|
+
return "其他業界重要訊息";
|
|
17
|
+
}
|
|
18
|
+
}
|
package/lib/justScrape.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { processHTML } from "./processHTML.mjs";
|
|
2
2
|
import { filterContent } from "./filterContent.mjs";
|
|
3
|
+
import { determineCategory } from "./determineCategory.mjs";
|
|
3
4
|
export function justScrape(link, html) {
|
|
4
5
|
try {
|
|
5
6
|
var scrapedContent = processHTML(link, html);
|
|
@@ -13,6 +14,7 @@ export function justScrape(link, html) {
|
|
|
13
14
|
Array.isArray(scrapedContent["date"])
|
|
14
15
|
? (scrapedContent["date"] = scrapedContent["date"].toString())
|
|
15
16
|
: "";
|
|
17
|
+
scrapedContent["category"] = determineCategory(scrapedContent["title"])
|
|
16
18
|
scrapedContent["url"] = link;
|
|
17
19
|
return scrapedContent;
|
|
18
20
|
} catch (error) {
|
package/package.json
CHANGED
package/sources/T1/UDNMoney.mjs
CHANGED
package/sources/T2/LTN3C.mjs
CHANGED
package/sources/T2/LTNEC.mjs
CHANGED
package/sources/T2/UDN.mjs
CHANGED
package/sources/T4/ETDAY.mjs
CHANGED
package/test.mjs
CHANGED
|
@@ -18,7 +18,7 @@ const testLinks = [
|
|
|
18
18
|
|
|
19
19
|
const buggedLinks = ["https://www.eprice.com.tw/mobile/talk/4523/5811558/1/"];
|
|
20
20
|
const testLink = [
|
|
21
|
-
"https://www.
|
|
21
|
+
"https://www.ettoday.net/news/20240905/2810968.htm",
|
|
22
22
|
];
|
|
23
23
|
async function getTestLinks() {
|
|
24
24
|
var response = [];
|