Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

document.querySelectorAll(".preview") + forEach

const { chromium } = require("playwright");
const fs = require("fs");

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto("https://danube-webshop.herokuapp.com");
  const content = await page.evaluate(() => {
    let data = [];

    let books = document.querySelectorAll(".preview");
    books.forEach((book) => {
      let title = book.querySelector(".preview-title").innerText;
      let author = book.querySelector(".preview-author").innerText;
      let price = book.querySelector(".preview-price").innerText;
      data.push({
        title,
        author,
        price,
      });
    });
    return data;
  });

  const jsonData = JSON.stringify(content);
  fs.writeFileSync("books.json", jsonData);
  await browser.close();
})();
Comment

PREVIOUS NEXT
Code Example
Javascript :: Cannot redefine property: clientWidth 
Javascript :: angularjs GetVideos API, Cant get the key parameter inside the array 
Javascript :: Call Injected AngularJs Service In Controller From Blazor Within CustomElement/WebComponent 
Javascript :: angularjs How can I write below code in better way to keep looping endlessly 
Javascript :: angularjs how to get a response from a post request 
Javascript :: Delete Button not working with json server using angularjs 
Javascript :: angularjs New Entry Not reflacting in table after inserting New record in CRUD angular app 
Javascript :: angularjs NodeJS server performs POST request, but returns HTTPErrorResponse 
Javascript :: How can I save a option from multi select in Angular 
Javascript :: how to use recursive function to select the parent in a tree array using angulat ui tree 
Javascript :: EXPO useEffect not called on navigating to same screen 
Javascript :: react table Maximum update depth exceeded. 
Javascript :: What is the best way to download mulitple images using jquery 
Javascript :: access language in request express 
Javascript :: in node.js with express how to remove the query string 
Javascript :: javascript polyIntersect 
Javascript :: javascript check if key is keydown is charcter 
Javascript :: show hide div in javascript 
Javascript :: in nav link if I click on the same active link, page has to refresh in react js 
Javascript :: phaser reverse matrix columns 
Javascript :: Creating New Transaction Object for blockchain 
Javascript :: Object methods + Static methods javascript 
Javascript :: Javascript Area When Base and Height is Known 
Javascript :: NodeJS Database initialisation 
Javascript :: check if first array contains all elements javascript 
Javascript :: on submit success jquery 
Javascript :: stringToCapital.js 
Javascript :: The most obvious example is handling the click event, 
Javascript :: Backbone Add To Collection 
Javascript :: selling partner api node install 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =