Ad Code

Ticker

6/recent/ticker-posts

Puppeteer Part III - Puppeteer Firefox

Puppeteer Firefox

Teknisi-Dadakan.Com - Puppeteer Firefox, Browser yang satu ini agak sulit di implentasikan dengan Puppeteer, tapi disini kita coba running Firefox dengan Puppeter, langsung aja kita otw sob.

Puppeteer Firefox, bagaimana sih caranya?

Seperti biasa,
  • Buka Aplikasi Visual Studio Code
  • Klik File, Open Folder dan buat Folder di directory sobat.
  • Klik Terminal, lalu pilih New Terminal
  • Lakukan init terlebih dahulu pada bagian terminal
npm init -y
  • Sebelum install library Puppeteer, lakukan config terlebih dahulu ketikan perintah berikut :
npm config set puppeteer_product=firefox
  • Lalu baru kita install library Puppeteer
npm install puppeteer
  • Dan install library console-title
npm i console-tittle
  • Lalu Paste kode berikut :
const puppeteer = require('puppeteer');
const setTitle  = require('console-title');

let title = "PUPPETEER FIREFOX - TEKNISI-DADAKAN.COM"    
setTitle(title)
let info;
info = (["\n",
"==========| PUPPETEER FIREFOX |============",
"      |  - TEKNISI-DADAKAN.COM - |",
"==========================================="
].join("\n"));

let url = 'https://teknisi-dadakan.com/';

console.log(info);

(async () => {
  const browser = await puppeteer.launch({
        headless: false,
        defaultViewport: null,
        args: ['--start-maximized'],
        product:'firefox',})

    const page = await browser.newPage();
    page.setDefaultNavigationTimeout(0);
    await page.goto(url);
    var tittle = await page.title();
    const urlpage = page.url();
    console.log("[-] Title Page : " + tittle + "\n" +
                "[-] URL Page   : " + urlpage);
 
 })();
  • Save dan Running via CMD
Selamat mencoba,
semoga bermanfaat,
salam satu aliran.
Teknisi-dadakan.

Posting Komentar

0 Komentar