-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrawler.js
More file actions
40 lines (35 loc) · 1.13 KB
/
crawler.js
File metadata and controls
40 lines (35 loc) · 1.13 KB
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
function wait(time) {
return new Promise(resolve => {
setTimeout(resolve, time);
});
}
const thumbs = document.getElementsByClassName('thumb');
let src = [];
for (var i = 2; i < thumbs.length; i++) {
console.log(i);
//title
let title = thumbs[i].parentElement.getElementsByTagName('td')[2].textContent;
title = title.replace(','," ");
//image
if(thumbs[i] && thumbs[i].children[0] && thumbs[i].children[0].href){
src.push(thumbs[i].children[0].href + " " + title);
await wait(200);
}
//video
else if(thumbs[i]) {
thumbs[i].click();
await wait(1000);
const iframes = document.getElementsByTagName('iframe');
if(iframes[1] && iframes[1].contentDocument){
contentDoc = iframes[1].contentDocument;
if(contentDoc.getElementsByTagName('iframe')[0]){
url = contentDoc.getElementsByTagName('iframe')[0].src;
schema = new URL(url);
src.push(schema.origin + schema.pathname + " " + title);
}
}
await wait(500);
thumbs[i].click();
}
}
src.join(',')