Open estatistics opened 9 months ago
how is taking login information from facebook / browser if i use different browser? I must use chrome or chromium?
Hey @estatistics 🖐
This problem is related to puppeteer. I don't have any idea
You don't need to login process for use the project. The project does't need to browser. You can select any browser you want
If the archive is empty, you can try this again;
1- Close the project terminal window
2- Open a new terminal window
3- Run yarn dev
I will try to debug puperteer. do you know how to make it more verbose the output? how to manipulate your code? eg. what urls try to access? it hits the right url? is there any login or other access issue? any error message that it is suppressed? these type of things.
The project go to the image url one by one, can you please check this; https://github.com/yasinatesim/facebook-album-downloader/blob/master/pages/api/download/index.ts#L67
and save the image one by one, please check below link; https://github.com/yasinatesim/facebook-album-downloader/blob/master/pages/api/download/index.ts#L75C11-L75C106
maybe there is a file write error, please you can try in the project folder;
chmod -R 777 .
I'm sorry I couldn't help because, I don't know Linux system. If you solve the error, please feel free to open PR
I am trying to learn pupeerteer! 2 problems. I run pupeteer without headless mode to see what happens.
1st) Calling chromium through pupeerteer requires login while running chromium from linux terminal, not require log in (cause provided already). I solved that by providing login.
2nd) By implementing your constant of photoLinks afterwards, does nothing in linux. 0 photos. I am trying to debug this now.
const puppeteer = require('puppeteer');
const fs = require('fs').promises; //for working with files
const userAgent = "Mozilla/5.0 ..........";
(async () => {
const browser = await puppeteer.launch({headless: false,
args: [
'--start-maximized',
'--no-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-infobars',
// '--window-position=0,0',
'--ignore-certifcate-errors',
'--ignore-certifcate-errors-spki-list',
// '--user-data-dir=' + rootDir,
],
executablePath: 'chromium'});
const page = await browser.newPage();
const context = browser.defaultBrowserContext();
await page.waitForTimeout(1150);
context.overridePermissions("https://www.facebook.com", ["geolocation", "notifications"]);
await page.goto('https://www.facebook.com/');
await page.keyboard.press('Enter'); // Enter Key
// Type in the username and continue forward
await page.waitForTimeout(1150);
await page.keyboard.type('USER', {delay: 120}); // Types slower, like a user
await page.keyboard.press('Tab'); // Enter Key
await page.keyboard.press('Tab'); // Enter Key
await page.keyboard.type('PASS, {delay: 120}); // Types slower, like a user
await page.keyboard.press('Enter'); // Enter Key
await page.waitForTimeout(7150);
//end here login
await page.goto('https://www.facebook.com/media/set/?set=a.623000739855658&type=3');
await page.waitForTimeout(5000);
const photoLinks = await page.evaluate(() => {
let links = [];
let photos = document.querySelectorAll<HTMLLinkElement>('[aria-label="Photo album photo"]');
for (let i = 0; i < photos.length; i++) {
links.push(photos[i].href);
}
return links;
});
console.log(`Found a total of ${photoLinks.length} photos.`);
await page.waitForNavigation();
//await page.screenshot({ path: 'facebook.png' });
// await browser.close();
})();
please tell me if running this code in your machine, like node fb_download.js
is working.
Change the path of course for chromium if needed.
login is required or not (based on your browser)
Hey @estatistics 👋
I've tried your code. I used Chrome browser.
I had to change the executubePath
👇
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: false,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
args: [
'--start-maximized',
'--no-sandbox',
'--disable-dev-shm-usage',
'--disable-gpu',
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-infobars',
// '--window-position=0,0',
'--ignore-certifcate-errors',
'--ignore-certifcate-errors-spki-list',
// '--user-data-dir=' + rootDir,
],
});
const page = await browser.newPage();
const context = browser.defaultBrowserContext();
await page.waitForTimeout(1150);
context.overridePermissions('https://www.facebook.com', ['geolocation', 'notifications']);
await page.goto('https://www.facebook.com/');
await page.keyboard.press('Enter'); // Enter Key
// Type in the username and continue forward
await page.waitForTimeout(1150);
await page.keyboard.type('USER', { delay: 120 }); // Types slower, like a user
await page.keyboard.press('Tab'); // Enter Key
await page.keyboard.press('Tab'); // Enter Key
await page.keyboard.type('PASS, {delay: 120}'); // Types slower, like a user
await page.keyboard.press('Enter'); // Enter Key
await page.waitForTimeout(7150);
//end here login
await page.goto('https://www.facebook.com/media/set/?set=a.623000739855658&type=3');
await page.waitForTimeout(5000);
const photoLinks = await page.evaluate(() => {
let links = [];
let photos = document.querySelectorAll < HTMLLinkElement > '[aria-label="Photo album photo"]';
for (let i = 0; i < photos.length; i++) {
links.push(photos[i].href);
}
return links;
});
console.log(`Found a total of ${photoLinks.length} photos.`);
await page.waitForNavigation();
//await page.screenshot({ path: 'facebook.png' });
// await browser.close();
})();
Please check the video 👇
it downloads empty zip files
Found a total of 0 photos.
Either running as
yarn start
or assudo yarn start
downloads empty zip files. I run chrome and login into facebook. Same problem.any idea how to debug this?
linux debian 12
i have firefox. i opened and entered localhost in chromium. again problem.
same with
yarn dev