Skip to content

Commit

Permalink
Merge pull request #3 from zainuldeen/master
Browse files Browse the repository at this point in the history
added: timetable screen shots
  • Loading branch information
Zain-ul-din authored Feb 11, 2024
2 parents a2030f9 + 6338333 commit bfea1d9
Show file tree
Hide file tree
Showing 237 changed files with 21 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/scrapper/meta_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export async function scrapeMetaData() {
await page.waitForSelector('#semester');
await page.waitForSelector("#semester option");


const dropDown = await page.$('#semester');

await dropDown?.select();

const semesters = (await page.evaluate(async () => {
return Array.from(document.querySelectorAll('#semester option')).map((element) =>
element.innerHTML.trim()
Expand Down
20 changes: 19 additions & 1 deletion src/scrapper/timetable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
///

import { Page } from 'puppeteer';
import { replaceAll, delay } from "../lib/util"

interface Payload {
semester: string;
Expand All @@ -11,6 +12,10 @@ interface Payload {
}

export async function scrapTimetable(payload: Payload, page: Page): Promise<any> {


await page.setViewport({width: 1400, height: 720 });

await page.waitForSelector('#semester');
const dropDown = await page.$('#semester');
await dropDown?.select();
Expand Down Expand Up @@ -58,10 +63,16 @@ export async function scrapTimetable(payload: Payload, page: Page): Promise<any>
await page.waitForNetworkIdle();
page.click('button[type=submit]');



// scrap timetable

await page.waitForNetworkIdle();
await delay(1)



const timetableData = await page.evaluate(() => {
Array.from(document.querySelectorAll(".footer-copyright")).forEach(ele => ele.style.display = 'none')
const tbody = Array.from(document.querySelectorAll('tr'));
tbody.splice(0, 1);
return tbody
Expand Down Expand Up @@ -97,5 +108,12 @@ export async function scrapTimetable(payload: Payload, page: Page): Promise<any>
}, {});
});

// take screen shot
await page.screenshot({
"type": "png",
"path": `./dist/${replaceAll(`${payload.semester} ${payload.program} ${payload.section}`,`/`,'-')}.png`,
"fullPage": true
})

return timetableData;
}

0 comments on commit bfea1d9

Please sign in to comment.