discogs-marketplace-api-nodejs 1.16.5 → 1.16.6
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.
|
@@ -47,7 +47,7 @@ function extractLegacy() {
|
|
|
47
47
|
* @param context Parent element to query from
|
|
48
48
|
* @returns Cleaned text content or an empty string
|
|
49
49
|
*/
|
|
50
|
-
const getTextContent = (selector, context = document) => context.querySelector(selector)?.textContent
|
|
50
|
+
const getTextContent = (selector, context = document) => context.querySelector(selector)?.textContent.trim() ?? '';
|
|
51
51
|
const total = safeParseInt(getTextContent('.pagination_total')
|
|
52
52
|
.split(' ')
|
|
53
53
|
.filter(x => x)
|
|
@@ -88,7 +88,7 @@ function extractLegacy() {
|
|
|
88
88
|
labels: [...el.querySelectorAll(".label_and_cat a[href^='https://www.discogs.com/']")]
|
|
89
89
|
.map(x => ({
|
|
90
90
|
id: safeParseInt(x.getAttribute('href')?.split('label/').pop()?.split('-').shift()),
|
|
91
|
-
name: x.textContent
|
|
91
|
+
name: x.textContent.trim(),
|
|
92
92
|
url: `https://www.discogs.com${x.getAttribute('href') ?? ''}`,
|
|
93
93
|
}))
|
|
94
94
|
.filter((value, index, self) => self.findIndex(v => v.name === value.name) === index),
|
|
@@ -66,7 +66,9 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
|
|
|
66
66
|
const browserPage = await browserContext.newPage();
|
|
67
67
|
await browserPage.setExtraHTTPHeaders({
|
|
68
68
|
'User-Agent': 'Discogs',
|
|
69
|
-
|
|
69
|
+
Accept: 'application/json',
|
|
70
|
+
'Accept-Language': 'en-US,en;q=0.9,fr-FR;q=0.8',
|
|
71
|
+
Referer: 'https://www.discogs.com/shop/mywants',
|
|
70
72
|
});
|
|
71
73
|
const response = await browserPage.goto(urlGenerated);
|
|
72
74
|
if (!response?.ok()) {
|
|
@@ -83,6 +85,19 @@ async function scrape({ currencies, genres, formats, formatDescriptions, conditi
|
|
|
83
85
|
headers: {
|
|
84
86
|
'User-Agent': 'Discogs',
|
|
85
87
|
'Content-Type': 'application/json',
|
|
88
|
+
Host: 'www.discogs.com',
|
|
89
|
+
Accept: '*/*',
|
|
90
|
+
'Accept-Language': 'en-US,en;q=0.9,fr-FR;q=0.8',
|
|
91
|
+
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
92
|
+
Referer: 'https://www.discogs.com/shop/mywants',
|
|
93
|
+
Origin: 'https://www.discogs.com',
|
|
94
|
+
'Alt-Used': 'www.discogs.com',
|
|
95
|
+
Connection: 'keep-alive',
|
|
96
|
+
'Sec-Fetch-Dest': 'empty',
|
|
97
|
+
'Sec-Fetch-Mode': 'cors',
|
|
98
|
+
'Sec-Fetch-Site': 'same-origin',
|
|
99
|
+
Priority: 'u=4',
|
|
100
|
+
TE: 'trailers',
|
|
86
101
|
},
|
|
87
102
|
body: JSON.stringify({
|
|
88
103
|
// eslint-disable-next-line max-len
|
|
@@ -19,16 +19,23 @@ async function scrapeWantlist(searchParams, browserContext) {
|
|
|
19
19
|
* @returns Links and total items found
|
|
20
20
|
*/
|
|
21
21
|
const getPageContent = async (pageNumber) => {
|
|
22
|
-
const
|
|
23
|
-
await browserPage.route('**/*', route => (route.request().resourceType() === 'document' ? route.continue() : route.abort()));
|
|
24
|
-
const response = await browserPage.goto(`https://www.discogs.com/wantlist?${new URLSearchParams({
|
|
22
|
+
const url = `https://www.discogs.com/wantlist?${new URLSearchParams({
|
|
25
23
|
page: pageNumber.toString(),
|
|
26
24
|
limit: PER_PAGE.toString(),
|
|
27
25
|
user: searchParams.wantlist ?? '',
|
|
28
26
|
layout: 'sm',
|
|
29
|
-
}).toString()}
|
|
27
|
+
}).toString()}`;
|
|
28
|
+
const browserPage = await browserContext.newPage();
|
|
29
|
+
await browserPage.setExtraHTTPHeaders({
|
|
30
|
+
'User-Agent': 'Discogs',
|
|
31
|
+
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
32
|
+
'Accept-Language': 'en-US,en;q=0.7,fr-FR;q=0.8',
|
|
33
|
+
Referer: url,
|
|
34
|
+
});
|
|
35
|
+
await browserPage.route('**/*', route => (route.request().resourceType() === 'document' ? route.continue() : route.abort()));
|
|
36
|
+
const response = await browserPage.goto(url);
|
|
30
37
|
const [total, ids] = await Promise.all([
|
|
31
|
-
browserPage.evaluate(() => +(document.querySelector('.pagination_total')?.textContent
|
|
38
|
+
browserPage.evaluate(() => +(document.querySelector('.pagination_total')?.textContent.split(' of ').pop()?.replace(',', '') ?? '0')),
|
|
32
39
|
browserPage.evaluate(() => {
|
|
33
40
|
/** Extract the links to the items in the wantlist, if there's no link it's not for sale */
|
|
34
41
|
const links = [...document.querySelectorAll('.marketplace_for_sale_count a')];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discogs-marketplace-api-nodejs",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.6",
|
|
4
4
|
"description": "Another (better ?) NodeJs library to fetch data from Discogs marketplace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"discogs",
|
|
@@ -40,30 +40,30 @@
|
|
|
40
40
|
}
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"playwright-chromium": "^1.
|
|
43
|
+
"playwright-chromium": "^1.58.2",
|
|
44
44
|
"playwright-extra": "^4.3.6",
|
|
45
45
|
"puppeteer-extra-plugin-stealth": "^2.11.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@eslint/js": "^9.
|
|
49
|
-
"@types/node": "^
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
51
|
-
"@typescript-eslint/parser": "^8.
|
|
52
|
-
"cspell": "^9.
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"eslint-config-prettier": "^10.1.
|
|
48
|
+
"@eslint/js": "^9.39.2",
|
|
49
|
+
"@types/node": "^22.19.11",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
|
51
|
+
"@typescript-eslint/parser": "^8.55.0",
|
|
52
|
+
"cspell": "^9.6.4",
|
|
53
|
+
"eslint": "^9.39.2",
|
|
54
|
+
"eslint-config-prettier": "^10.1.8",
|
|
55
55
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
56
56
|
"eslint-plugin-import": "^2.32.0",
|
|
57
|
-
"eslint-plugin-jsdoc": "^
|
|
58
|
-
"globals": "^
|
|
57
|
+
"eslint-plugin-jsdoc": "^62.5.5",
|
|
58
|
+
"globals": "^17.3.0",
|
|
59
59
|
"husky": "^9.1.7",
|
|
60
|
-
"knip": "^5.
|
|
61
|
-
"lint-staged": "^16.
|
|
62
|
-
"prettier": "^3.
|
|
63
|
-
"rimraf": "^6.
|
|
60
|
+
"knip": "^5.83.1",
|
|
61
|
+
"lint-staged": "^16.2.7",
|
|
62
|
+
"prettier": "^3.8.1",
|
|
63
|
+
"rimraf": "^6.1.2",
|
|
64
64
|
"tsc-alias": "^1.8.16",
|
|
65
|
-
"tsx": "^4.
|
|
66
|
-
"typescript": "^5.
|
|
67
|
-
"typescript-eslint": "^8.
|
|
65
|
+
"tsx": "^4.21.0",
|
|
66
|
+
"typescript": "^5.9.3",
|
|
67
|
+
"typescript-eslint": "^8.55.0"
|
|
68
68
|
}
|
|
69
69
|
}
|