-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcircle-detail-downloader.js
75 lines (64 loc) · 3.69 KB
/
circle-detail-downloader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* You need to change "arrLink" variable for circle list
* then enter this script in DevTools's console when you open circle page like https://webcatalog.circle.ms/Circle/15130724
* Notes that url may become webcatalog-free.circle.ms if you get links via webcatalog-free's console.
*/
//WebCatalog circle link list
const arrLink = ['https://webcatalog.circle.ms/Circle/15130724'];
//Query selector list
const strQueryCircleName = '#mainSection > div.m-media.m-circletable > div.m-media__body.md-circleinfo > div.item > table > tbody > tr:nth-child(1) > td:nth-child(2) > a:nth-child(1)';
const strQueryCircleDayPos = '#mainSection > div.m-media.m-circletable > div.m-media__body.md-circleinfo > div.item > table > tbody > tr:nth-child(1) > td:nth-child(4)';
const strQueryWriterName = '#mainSection > div.m-media.m-circletable > div.m-media__body.md-circleinfo > div.item > table > tbody > tr:nth-child(2) > td:nth-child(2)';
const strQueryTwitter = '#mainSection > div.m-media.m-circletable > div.m-media__body.md-circleinfo > div.item > table > tbody > tr:nth-child(3) > td > div > ul > li:nth-child(5) > a';
const strQueryECList = '#mainSection > div.m-media.m-circletable > div.m-media__body.md-circleinfo > div.item > table > tbody > tr:nth-child(4) > td > div > ul > li';
const strQueryECLink = 'div > a';
// Iterate link list
for(const strLink of arrLink) {
//Fetch Data
let objResponse = await fetch(strLink);
//Check Reponse
if(objResponse.ok) {
//For save link as object
let objLink = new Object();
//Parse DOM
let domParser = new DOMParser();
let objParsedDOC = domParser.parseFromString(await objResponse.text(), 'text/html');
//Circle name
let strCircleName = objParsedDOC.querySelector(strQueryCircleName).innerText.trim();
//Circle position and day
let strCircleDayPos = objParsedDOC.querySelector(strQueryCircleDayPos).innerText.trim();
//Writer name
let strWriterName = objParsedDOC.querySelector(strQueryWriterName).innerText.trim();
//Twitter link
let strTwitterLink = objParsedDOC.querySelector(strQueryTwitter).href;
//Online shop list
let arrECList = objParsedDOC.querySelectorAll(strQueryECList);
//Check does it has online shop link
if(arrECList.length > 0) {
//Iterate shop link
for(const eleEC of arrECList) {
//Online shop link query
let strECLink = eleEC.querySelector(strQueryECLink).href;
//Filtering link
if(strECLink.startsWith('https://ec.toranoana.jp')){
//Tora no ana
objLink.toranoana = strECLink;
}else if(strECLink.startsWith('https://www.melonbooks.co.jp')){
//Melonbooks
objLink.melonbooks = strECLink;
}else if(strECLink.startsWith('https://www.dlsite.com')){
//DLsite
objLink.dlsite = strECLink;
}else if(strECLink.endsWith('booth.pm/')){
//BoothPM
objLink.boothpm = strECLink;
}else if(strECLink.startsWith('http://www.dmm.co.jp')){
//Fanza
objLink.fanza = strECLink;
}
}
}
//Print
console.info(`${strCircleName}\t${strCircleDayPos}\t${strWriterName}\t${strTwitterLink}\t${strLink}\t${objLink.toranoana === undefined ? '' : objLink.toranoana}\t${objLink.melonbooks === undefined ? '' : objLink.melonbooks}\t${objLink.dlsite === undefined ? '' : objLink.dlsite}\t${objLink.boothpm === undefined ? '' : objLink.boothpm}\t${objLink.fanza === undefined ? '' : objLink.fanza}`);
}
}