Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

438
Views
Node app not writing to a file, no error logs

I am trying to use Capture-Website which saves screenshots of webpages to a file.

It used to work perfectly until I restarted the server.

Now the code runs without errors, but it does NOT save a screenshot to disk

Here is my code:

import http from 'http';
import url from 'url';
import querystring from 'querystring';

var mainURL;

const hostname = 'localhost';
const port = 8080;


import captureWebsite from 'capture-website';


const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World!\n');
    var url_parts = url.parse(req.url, true);
    var query = url_parts.query;
    mainURL = query.url;
    console.log(mainURL);
    (async () => {
        try {
            await captureWebsite.file('https://'+mainURL, mainURL+".jpg", {
                overwrite:true,
                type: 'jpeg',
                quality: 0.5,
                width:1480,
                height:800,
                delay: 1
            });
        }
        catch(err) {
            console.log(err);
        }
    })();
    
});

There are no errors. I have also tried running pm2 logs - no errors there either.

Here is the file-writing code that belongs to the capture-website package:

captureWebsite.file = async (url, filePath, options = {}) => {
    const screenshot = await internalCaptureWebsite(url, options);

    
    await fs.writeFile(filePath, screenshot, {
        flag: options.overwrite ? 'w' : 'wx',
    });
    
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your problem is most likely that you can not use Slashes (/) in file names. This is because folders are seperated with slashes.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!