Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed May 25, 2024
1 parent 61f17fe commit a3debe3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,27 @@ const initializeCrawler = async () => {
minConcurrency: 5,
maxConcurrency: 15,
launchContext: {
launchOptions: {
defaultViewport: {
width: 1512,
height: 982,
},
},
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
},
requestHandler: async ({ request, page }) => {
await page.waitForNetworkIdle();

await Promise.all([
page
.evaluate(() => window.scrollBy(0, window.innerHeight))
.then(() => page.waitForTimeout(152)),
page
.evaluate(() => window.scrollBy(0, window.innerHeight))
.then(() => page.waitForTimeout(204)),
]);

const content = await page.content();
console.log(`Title: ${await page.title()}`);
console.log(`Content: ${content}`);
Expand All @@ -49,7 +65,7 @@ const addToQueue = async (queue, url, uniqueKey) => {
await queue.addRequests([{ url, uniqueKey }]);
};

const getContent = async (uniqueKey, maxRetries = 10, delay = 1000) => {
const getContent = async (uniqueKey, maxRetries = 20, delay = 1000) => {
for (let i = 0; i < maxRetries; i++) {
if (contentMap.has(uniqueKey)) {
const content = contentMap.get(uniqueKey);
Expand Down

0 comments on commit a3debe3

Please sign in to comment.