How to wirte file from browser site in node.js

I have created addons for firefox to scrape google search page web links.
Screenshot 2022-09-27 201611

This is my main program file:

let webNum = 5;

function scrapeLinks(num){
    let links = document.querySelectorAll('.yuRUbf a'), hrefs = [];
    for (let i = 0; i < num; i++) { hrefs.push(links[i].href) };
    return hrefs.join(" ");
const allLinks = scrapeLinks(webNum);

const fs = require("fs");

function writeInFile(content){
    fs.writeFileSync("H:/python projects/Rafiq A.I/scrape addons/data/weblinks.txt", content, err => {
        if (err) {


I scrape all website links from the google search page and store them on allLinks variable. It works I check it on the console. But my writeInFile function does not work in the browser. But it works when I run it on the node js terminal. I want to make a program to scrape my data and store it on the txt file. How can I do this?

The easiest way to write to files in Node.js is to use the fs.writeFile() API.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.