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') We then navigate to that URL using the page.goto() function.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. We then get the url of the page we want to download the image from the user and stored it in a variable named baseURL. We can now heedlessly control this page from our code. Think of this page as the new page you get after launching your chrome browser. In that function, we created an instance of a browser page using puppeteer and stored it in the page constant. First, we created an async function called extractImageLinks. Now let me explain what is happening here. Enter fullscreen mode Exit fullscreen mode
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |