Open RossBaptie opened 4 years ago
Can you try installing some prerequisites?
sudo apt-get install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
This ticket suggests using the Raspberry Pi's ARM built chromium rather than puppeteer's native Chrome.
sudo apt-get install chromium-browser
Then updating the code to use it by adding
const browser = await puppeteer.launch({ executablePath: 'chromium-browser' });
Hi Paul - thank you for your help.
I did all these three steps, but now when I do 'yarn start' I get the following error mesage
pi@raspberrypi:~/delivery-slot-bot $ yarn start
yarn run v1.22.4
$ node ./src/index.js
/home/pi/delivery-slot-bot/src/index.js:1
const browser = await puppeteer.launch({ executablePath: 'chromium-browser' });
^^^^^
SyntaxError: await is only valid in async function
at wrapSafe (internal/modules/cjs/loader.js:1070:16)
at Module._compile (internal/modules/cjs/loader.js:1120:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
error Command failed with exit code 1.
I appreciate I am out my depth here, but if there's anything obvious here any help would be greatly appreciate - thanks!
I think the const browser = await puppeteer.launch({ executablePath: 'chromium-browser' });
code may be to replace the existing const browser =
statement on line 14.
Thanks Paul - I did that and now progressed to this error message now
ReferenceError: puppeteer is not defined
at runStore (/home/pi/delivery-slot-bot/src/index.js:14:19)
at run (/home/pi/delivery-slot-bot/src/index.js:50:11)
at Object.handler (/home/pi/delivery-slot-bot/src/index.js:63:43)
at Object.runCommand (/home/pi/delivery-slot-bot/node_modules/yargs/lib/command.js:240:40)
at Object.parseArgs [as _parseArgs] (/home/pi/delivery-slot-bot/node_modules/yargs/yargs.js:1182:35)
at Object.get [as argv] (/home/pi/delivery-slot-bot/node_modules/yargs/yargs.js:1088:21)
at Object.<anonymous> (/home/pi/delivery-slot-bot/src/index.js:64:10)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
error Command failed with exit code 1.
Thanks Paul - I did that and now progressed to this error message now
ReferenceError: puppeteer is not defined at runStore (/home/pi/delivery-slot-bot/src/index.js:14:19) at run (/home/pi/delivery-slot-bot/src/index.js:50:11) at Object.handler (/home/pi/delivery-slot-bot/src/index.js:63:43) at Object.runCommand (/home/pi/delivery-slot-bot/node_modules/yargs/lib/command.js:240:40) at Object.parseArgs [as _parseArgs] (/home/pi/delivery-slot-bot/node_modules/yargs/yargs.js:1182:35) at Object.get [as argv] (/home/pi/delivery-slot-bot/node_modules/yargs/yargs.js:1088:21) at Object.<anonymous> (/home/pi/delivery-slot-bot/src/index.js:64:10) at Module._compile (internal/modules/cjs/loader.js:1156:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10) at Module.load (internal/modules/cjs/loader.js:1000:32) at Function.Module._load (internal/modules/cjs/loader.js:899:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 error Command failed with exit code 1.
I am also getting the same. Please help!
Hi, @paulmaunders do u think u can help with the issue above with the "puppeteer is not defined". Thanks
OK I've set it up on my own Raspberry Pi so I can test it properly and I managed to get it working. You need to make the following changes:
index a2b8760..8f33c35 100644
--- a/src/index.js
+++ b/src/index.js
@@ -11,7 +11,8 @@ const { handleSlots } = require("./slot-handler");
* @param {Store} store
*/
async function runStore(store) {
- const browser = await getBrowser();
+ const browser = await getBrowser({ executablePath: 'chromium-browser' });
+
const userAgent =
config.raw.useragent ||
(await browser.userAgent()).replace(/headless/i, "");
diff --git a/src/puppeteer-utils.js b/src/puppeteer-utils.js
index ff97243..9fdbfc6 100644
--- a/src/puppeteer-utils.js
+++ b/src/puppeteer-utils.js
@@ -4,13 +4,13 @@ const puppeteer = require("puppeteer");
/** @typedef {import("puppeteer").Page} Page */
/** @typedef {import("puppeteer").Response} Response */
-function getBrowser() {
+function getBrowser($args) {
if (process.env.PUPPETEER_BROWSER_WS_ENDPOINT) {
return puppeteer.connect({
browserWSEndpoint: process.env.PUPPETEER_BROWSER_WS_ENDPOINT,
});
}
- return puppeteer.launch();
+ return puppeteer.launch($args);
}
/**
@andytson could we add exectuablePath as an option in config.ini? e.g. so people can just uncomment it to get it working on Raspberry Pi?
that's great - thanks very much Paul - works for me now!
Excellent, thank you @paulmaunders it worked for me as well 🙂👍 It will be great as you suggested if this is a toggle in the config.ini file to enable or disable Raspberry Pi.
@andytson would you mind tidying up the patch I provided as a config var?
Hi - sorry for this as it's probably a stupid newbie question, but I am trying to set this up to help find delivery & pick up slots for several elderly and vulnerable people in our mutual aid group but i'm pretty clueless around all this.
I'm running this on a Raspberry Pi 3 - have done all the installation stuff and when I do
yarn start
I get this error message:-
Error: Failed to launch chrome! /home/pi/delivery-slot-bot/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: 1: /home/pi/delivery-slot-bot/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: Syntax error: Unterminated quoted string
Appreciate this is probably not specific to this bot but not really sure where else to ask for help
Any help would be greatly appreciated!
Thanks