Advertisement
ghiwar

Simpan data produk di https://shop.tiktok.com/ kedalam csv

Dec 12th, 2024 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Simpan data produk di https://shop.tiktok.com/ kedalam csv
  2. // contact t.me/mase89
  3. // Array untuk menyimpan data exposure key
  4. const data = [];
  5.  
  6. // Seleksi semua elemen yang memiliki atribut `data-exposure-key`
  7. document.querySelectorAll('[data-exposure-key]').forEach(el => {
  8.     const key = el.getAttribute('data-exposure-key');
  9.     if (key) {
  10.         // Format URL
  11.         const url = `https://shop.tiktok.com/view/product/${key}?region=ID`;
  12.         data.push(url);
  13.     }
  14. });
  15.  
  16. // Konversi array menjadi konten CSV
  17. const csvContent = "data:text/csv;charset=utf-8," + data.join("\n");
  18.  
  19. // Buat dan klik elemen download untuk menyimpan file
  20. const encodedUri = encodeURI(csvContent);
  21. const link = document.createElement("a");
  22. link.setAttribute("href", encodedUri);
  23. link.setAttribute("download", "data_produk.csv");
  24. document.body.appendChild(link);
  25. link.click();
  26. document.body.removeChild(link);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement