Small notes changes. Added HackerRank Internal's Templates
This commit is contained in:
@ -59,45 +59,49 @@ async function courseOverview(id, i, num) {
|
||||
const page = await browser.newPage();
|
||||
const course = url+id+uid;
|
||||
console.log(course)
|
||||
await page.setViewport({ width:390, height:844 })
|
||||
await page.goto(course, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0 });
|
||||
if (course.includes("undefined")) {
|
||||
console.log("Error - Undefined UUID. Possibly end of list. Exiting.")
|
||||
} else {
|
||||
await page.setViewport({ width:390, height:844 })
|
||||
await page.goto(course, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0 });
|
||||
|
||||
await page.title();
|
||||
const [getXpath] = await page.$x('/html/body/div[2]/div/div');
|
||||
const resourcetitle = await page.evaluate(name => name.innerText, getXpath);
|
||||
const resource = resourcetitle.trim();
|
||||
console.log(resource);
|
||||
await page.title();
|
||||
const [getXpath] = await page.$x('/html/body/div[1]/div');
|
||||
const resourcetitle = await page.evaluate(name => name.innerText, getXpath);
|
||||
const resource = resourcetitle.trim();
|
||||
console.log(resource);
|
||||
|
||||
await page.screenshot({path: `${resource}_1.png`, fullPage:true, headless:false});
|
||||
await page.screenshot({path: `${resource}_1.png`, fullPage:true, headless:false});
|
||||
|
||||
const hrefs = await page.$$eval('a', as => as.map(a => a.href));
|
||||
var links = Object.entries(hrefs);
|
||||
links.forEach(([key, value]) => {
|
||||
var link = value;
|
||||
if (link.includes("activities") && (link.includes(id))) {
|
||||
console.log(link);
|
||||
activity.push(link);
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
const hrefs = await page.$$eval('a', as => as.map(a => a.href));
|
||||
var links = Object.entries(hrefs);
|
||||
links.forEach(([key, value]) => {
|
||||
var link = value;
|
||||
if (link.includes("activities") && (link.includes(id))) {
|
||||
console.log(link);
|
||||
activity.push(link);
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
|
||||
}, 5000);
|
||||
uniqueLinks = [...new Set(activity)];
|
||||
for (const link of uniqueLinks) {
|
||||
num = num+1
|
||||
const newlink = link+uid;
|
||||
await page.setViewport({ width: 390, height: 844 })
|
||||
await page.goto(newlink, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0 });
|
||||
await page.screenshot({path: `${resource}_${num}.png`, fullPage: true, headless: false});
|
||||
//screenshots(newlink, resource, num, i);
|
||||
}
|
||||
await browser.close();
|
||||
i++;
|
||||
loopIds(i);
|
||||
}, 5000);
|
||||
uniqueLinks = [...new Set(activity)];
|
||||
for (const link of uniqueLinks) {
|
||||
num = num+1
|
||||
const newlink = link+uid;
|
||||
await page.setViewport({ width: 390, height: 844 })
|
||||
await page.goto(newlink, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0 });
|
||||
await page.screenshot({path: `${resource}_${num}.png`, fullPage: true, headless: false});
|
||||
//screenshots(newlink, resource, num, i);
|
||||
}
|
||||
await browser.close();
|
||||
i++;
|
||||
loopIds(i);
|
||||
}
|
||||
}
|
||||
|
||||
async function screenshots(newlink, resource, num, i) {
|
||||
|
||||
Reference in New Issue
Block a user