![]() ![]() ![]() How to pass userDataDir profile folder to Puppeteer The first time you run the above code, you will have to comment out the fs.readFile to fs.writeFile as the UserDirDirectory is created if it does not exist the first time that Chrome is started.Īll profile related data is then stored in the customChrome/Default folder. ![]() Essentially, Puppeteer creates a custom profile each time it runs, we can override that profile and define the download directory. This will set the default download directory for files before the process starts. _directory = path.resolve(_dirname, './downloads') įs.writeFileSync(customChrome+'/Default/Preferences', JSON.stringify(obj)) Īrgs: _directory = path.resolve(_dirname, './downloads') Let prefs = fs.readFileSync(customChrome+'/Default/Preferences') ![]() I was able to set the download location using the following code, let customChrome = path.resolve(_dirname, './customChrome') node_modules # Run everything after as non-privileged user.I realize this is an old thread, but this thread popped up first for me when looking for how to set Puppeteer default download location. & chown -R pptruser:pptruser /home/pptruser \ RUN groupadd -r pptruser & useradd -r -g pptruser -G audio,video pptruser \ app/ #COPY nf /etc/fonts/nf WORKDIR app RUN npm i # Add user so we don't need -no-sandbox. # If you do, you'll need to launch puppeteer with: # browser.launch() # ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true # Copy the app COPY. ADD /usr/local/bin/dumb-init RUN chmod +x /usr/local/bin/dumb-init # Uncomment to skip the chromium download when installing puppeteer. & rm -rf /src/*.deb # It's a good idea to use dumb-init to help prevent zombie chrome processes. & apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \ & sh -c 'echo "deb stable main" > /etc/apt//google.list' \ RUN apt-get update & apt-get install -y wget -no-install-recommends \ FROM node:8-slim LABEL name "puppeteraas" # See RUN apt-get update & apt-get install -yq libgconf-2-4 # Install latest chrome dev package and fonts to support major # charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others) # Note: this installs the necessary libs to make the bundled version # of Chromium that Puppeteer # installs, work. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |