Skip to content
Sign upLog in
← Back to Community

This time we *are* getting puppeteer

Profile icon
Coder100Hacker

This time puppeteer is going to save

Hello everyone! Just yesterday I installed node.js locally on my computer for some Heroku business: https://arcane-peak-83337.herokuapp.com/ which also ultimately caused the empty repl project! Today, we are going to be going above that. WE are going to use puppeteer! Before, you had to go to pygame and use webbot. Now we are going to use bash, and use puppeteer which is way better because you are using node.js.

Recreation

npm init

Fill in questionnaire and you should have a package.json

npm install puppeteer --save

This is where we get puppeteer.

npm install puppeteer --save && npm start

JK this is how we do the real stuff. We install then run.

const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: false, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); const page = await browser.newPage(); page.goto("https://repl.it/"); // More commands here... /* You may view the docs at: https://devdocs.io/puppeteer/ And more magic at: https://www.npmjs.com/package/puppeteer Github: https://github.com/puppeteer/puppeteer */ // await browser.close(); })();

Real easy here, you just do the stuff. Notice on line 4. These args are absolutely necessary due to some restrictions set out by repl.it I think this is the reason for --no-sandbox because if you leave that out, you get some cryptic errors.


Enjoy!

Fork and let's unblock some things! may I suggest surviv?

Please vote up if you liked this tutorial of sorts!

Happy unblocking!

Giving credit

This was made entirely by me and you can give credit by putting

// This REPL was made thanks to repl.it/@Coder100/This-time-we-are-getting-puppeteer // Go fork it and check it out!

Some side comments

For embedding, try ?lite=true&outputonly=1

Voters
Profile icon
teleweb
Profile icon
andikavikar135
Profile icon
XiaoyiAtReplit
Profile icon
Skysea28957
Profile icon
CharanChandran
Profile icon
DaviMacedo4
Profile icon
Bhone-MM
Profile icon
waki285
Profile icon
Abdullah2222
Profile icon
juansegnana
Comments
hotnewtop
Profile icon
hazelpy

Yo hell yeah surviv! Man I'm so glad this works, I'll use this during school fno lol

Profile icon
Coder100

Lol

@hazelpy

Profile icon
moni13

doesn't work on me

Profile icon
Evanlicious

@Coder100
I actually just made something like this a day ago, you can just run Chromium from a .sh file on repl.it. All you have to do is type in "chromium-browser --no-sandbox" and it's done.

Profile icon
Coder100

Well yeah, but can you automate it? Also, this build of chrome appears to be on a chromebook

@Evanlicious

Profile icon
Evanlicious

@Coder100
You might be able to, but I am not sure.

Profile icon
Coder100

hmmm ill look at that

@Evanlicious

Profile icon
noodles37

This seems really cool but can someone explain how it works :) thx

Profile icon
Coder100

What part do you not understand? We have to use all those await things because node.js is asynchronous by default, so without them, it will open and close at the same time really bad

@SilentShadowBla

Profile icon
Eevee9890

Bro, I fork the repl and getting error
This is my code :-
const puppeteer = require('puppeteer');

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.youtube.com/');
await page.screenshot({ path: 'YouTube.png' });

await browser.close();
})();

error:-
Failed to launch the browser process! [0602/115934.354886:FATAL:zygote_host_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox. #0 0x55ec0840c219 base::debug::CollectStackTrace() #1 0x55ec08370363 base::debug::StackTrace::StackTrace() #2 0x55ec08382195 logging::LogMessage::~LogMessage() #3 0x55ec09bfe00e service_manager::ZygoteHostImpl::Init() #4 0x55ec07f79f27 content::ContentMainRunnerImpl::Initialize() #5 0x55ec07fc8afa service_manager::Main() #6 0x55ec07f78501 content::ContentMain() #7 0x55ec07fc78f5 headless::(anonymous namespace)::RunContentMain() #8 0x55ec07fc759d headless::HeadlessShellMain() #9 0x55ec05b3caa7 ChromeMain #10 0x7f8f4cc4bbf7 __libc_start_main #11 0x55ec05b3c8ea _start Received signal 6 #0 0x55ec0840c219 base::debug::CollectStackTrace() #1 0x55ec08370363 base::debug::StackTrace::StackTrace() #2 0x55ec0840bd61 base::debug::(anonymous namespace)::StackDumpSignalHandler() #3 0x7f8f52cbc980 #4 0x7f8f4cc68fb7 gsignal #5 0x7f8f4cc6a921 abort #6 0x55ec0840ab65 base::debug::BreakDebugger() #7 0x55ec08382634 logging::LogMessage::~LogMessage() #8 0x55ec09bfe00e service_manager::ZygoteHostImpl::Init() #9 0x55ec07f79f27 content::ContentMainRunnerImpl::Initialize() #10 0x55ec07fc8afa service_manager::Main() #11 0x55ec07f78501 content::ContentMain() #12 0x55ec07fc78f5 headless::(anonymous namespace)::RunContentMain() #13 0x55ec07fc759d headless::HeadlessShellMain() #14 0x55ec05b3caa7 ChromeMain #15 0x7f8f4cc4bbf7 __libc_start_main #16 0x55ec05b3c8ea _start r8: 0000000000000000 r9: 00007ffcf7fc3920 r10: 0000000000000008 r11: 0000000000000246 r12: 00007ffcf7fc4be8 r13: 00007ffcf7fc3bc0 r14: 00007ffcf7fc4bf0 r15: aaaaaaaaaaaaaaaa di: 0000000000000002 si: 00007ffcf7fc3920 bp: 00007ffcf7fc3b70 bx: 00007ffcf7fc3be4 dx: 0000000000000000 ax: 0000000000000000 cx: 00007f8f4cc68fb7 sp: 00007ffcf7fc3920 ip: 00007f8f4cc68fb7 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000 [end of stack trace] Calling _exit(1). Core file will not be generated. TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md at onClose (/home/runner/Puppeteer/node_modules/puppeteer/lib/Launcher.js:750:14) at Interface. (/home/runner/Puppeteer/node_modules/puppeteer/lib/Launcher.js:739:50) at Interface.emit (events.js:387:35) at Interface.close (readline.js:451:8) at Socket.onend (readline.js:224:10) at Socket.emit (events.js:387:35) at endReadableNT (internal/streams/readable.js:1317:12) at processTicksAndRejections (internal/process/task_queues.js:82:21) (Use node --trace-warnings ... to show where the warning was created) (node:70) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:70) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

PLEASE HELP ME!

Profile icon
Coder100

try using nix

@Eevee9890

Profile icon
Eevee9890

@Coder100
Thanks a lot bruh, now it's working

Profile icon
CharanChandran

@Coder100
What do you do using nix? I have the same problem. Since I tried to do the same to my own bash replit and it doesn't recognize npm or node.

Profile icon
CharanChandran

@Coder100
What replit.nix and .replit files did you use? Thank you for any help.

Profile icon
CharanChandran

@Coder100
Also using express in combination does no work.

Profile icon
nodexninja

Wait this actually worked.

Profile icon
Coder100

@nodexninja
yep that's how working works

Profile icon
qaiik

I am using automation to unblock, get the headers normally used when requesting, and use them

Profile icon
shirser121

You help me so much!
Thank you!!
I have no words to say how much you help me!

Profile icon
Blankjp

How do you see the output?

Profile icon
MarioX

show how enable/install/execute puppeteer-core + chrome with plugins enable
https://repl.it/talk/share/fixing-puppeteer-core-and-chrome-with-plugins/84218

Profile icon
johniskander

I got this error :
TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r722234 is guaranteed to work.

have any idea why ?

Profile icon
mwilki7

what does this do?

Profile icon
hazelpy

@mwilki7
unblock tool for school/work computers

Profile icon
Coder100

Yes, and also automation things but unblocking is more fun lol

@hazelpy

Profile icon
RohilPatel

Noice!